<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The University of Glasgow 2006
(c) The GRASP/AQUA Project, Glasgow University, 1992-1998

-}</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# LANGUAGE CPP, MultiWayIf, TupleSections #-}</span><span>
</span><span id="line-8"></span><span class="hs-pragma">{-# LANGUAGE FlexibleContexts #-}</span><span>
</span><span id="line-9"></span><span>
</span><span id="line-10"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-uni-patterns   #-}</span><span>
</span><span id="line-11"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}</span><span>
</span><span id="line-12"></span><span>
</span><span id="line-13"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Tc.Utils.Instantiate</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-14"></span><span>       </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#topSkolemise"><span class="hs-identifier">topSkolemise</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-15"></span><span>       </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#topInstantiate"><span class="hs-identifier">topInstantiate</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#topInstantiateInferred"><span class="hs-identifier">topInstantiateInferred</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-16"></span><span>       </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#instCall"><span class="hs-identifier">instCall</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#instDFunType"><span class="hs-identifier">instDFunType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#instStupidTheta"><span class="hs-identifier">instStupidTheta</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#instTyVarsWith"><span class="hs-identifier">instTyVarsWith</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-17"></span><span>       </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newWanted"><span class="hs-identifier">newWanted</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html#newWanteds"><span class="hs-identifier">newWanteds</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-18"></span><span>
</span><span id="line-19"></span><span>       </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstType"><span class="hs-identifier">tcInstType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstTypeBndrs"><span class="hs-identifier">tcInstTypeBndrs</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-20"></span><span>       </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstSkolTyVars"><span class="hs-identifier">tcInstSkolTyVars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstSkolTyVarsX"><span class="hs-identifier">tcInstSkolTyVarsX</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstSkolTyVarsAt"><span class="hs-identifier">tcInstSkolTyVarsAt</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>       </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcSkolDFunType"><span class="hs-identifier">tcSkolDFunType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcSuperSkolTyVars"><span class="hs-identifier">tcSuperSkolTyVars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstSuperSkolTyVarsX"><span class="hs-identifier">tcInstSuperSkolTyVarsX</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span>       </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#freshenTyVarBndrs"><span class="hs-identifier">freshenTyVarBndrs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#freshenCoVarBndrsX"><span class="hs-identifier">freshenCoVarBndrsX</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-24"></span><span>
</span><span id="line-25"></span><span>       </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstInvisibleTyBindersN"><span class="hs-identifier">tcInstInvisibleTyBindersN</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstInvisibleTyBinders"><span class="hs-identifier">tcInstInvisibleTyBinders</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstInvisibleTyBinder"><span class="hs-identifier">tcInstInvisibleTyBinder</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-26"></span><span>
</span><span id="line-27"></span><span>       </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#newOverloadedLit"><span class="hs-identifier">newOverloadedLit</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#mkOverLit"><span class="hs-identifier">mkOverLit</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-28"></span><span>
</span><span id="line-29"></span><span>       </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#newClsInst"><span class="hs-identifier">newClsInst</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-30"></span><span>       </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcGetInsts"><span class="hs-identifier">tcGetInsts</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#tcGetInstEnvs"><span class="hs-identifier">tcGetInstEnvs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#getOverlapFlag"><span class="hs-identifier">getOverlapFlag</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-31"></span><span>       </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcExtendLocalInstEnv"><span class="hs-identifier">tcExtendLocalInstEnv</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-32"></span><span>       </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#instCallConstraints"><span class="hs-identifier">instCallConstraints</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#newMethodFromName"><span class="hs-identifier">newMethodFromName</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-33"></span><span>       </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcSyntaxName"><span class="hs-identifier">tcSyntaxName</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span>       </span><span class="hs-comment">-- Simple functions over evidence variables</span><span>
</span><span id="line-36"></span><span>       </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#tyCoVarsOfWC"><span class="hs-identifier">tyCoVarsOfWC</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-37"></span><span>       </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#tyCoVarsOfCt"><span class="hs-identifier">tyCoVarsOfCt</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#tyCoVarsOfCts"><span class="hs-identifier">tyCoVarsOfCts</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-38"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-43"></span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="hs-pragma">{-# SOURCE</span><span> </span><span class="hs-pragma">#-}</span><span>   </span><span class="annot"><a href="GHC.Tc.Gen.Expr.html"><span class="hs-identifier">GHC.Tc.Gen.Expr</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Expr.html#tcCheckPolyExpr"><span class="hs-identifier">tcCheckPolyExpr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Expr.html#tcSyntaxOp"><span class="hs-identifier">tcSyntaxOp</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="hs-pragma">{-# SOURCE</span><span> </span><span class="hs-pragma">#-}</span><span>   </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html"><span class="hs-identifier">GHC.Tc.Utils.Unify</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#unifyType"><span class="hs-identifier">unifyType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html#unifyKind"><span class="hs-identifier">unifyKind</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-46"></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#IntegralLit"><span class="hs-identifier">IntegralLit</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#SourceText"><span class="hs-identifier">SourceText</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Hs.html"><span class="hs-identifier">GHC.Hs</span></a></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Zonk.html"><span class="hs-identifier">GHC.Tc.Utils.Zonk</span></a></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Monad.html"><span class="hs-identifier">GHC.Tc.Utils.Monad</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html"><span class="hs-identifier">GHC.Tc.Types.Constraint</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html"><span class="hs-identifier">GHC.Core.Predicate</span></a></span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html"><span class="hs-identifier">GHC.Tc.Types.Origin</span></a></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html"><span class="hs-identifier">GHC.Tc.Utils.Env</span></a></span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html"><span class="hs-identifier">GHC.Tc.Types.Evidence</span></a></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.InstEnv.html"><span class="hs-identifier">GHC.Core.InstEnv</span></a></span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.html"><span class="hs-identifier">GHC.Builtin.Types</span></a></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.html#heqDataCon"><span class="hs-identifier">heqDataCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.html#eqDataCon"><span class="hs-identifier">eqDataCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Builtin.Types.html#integerTyConName"><span class="hs-identifier">integerTyConName</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.html"><span class="hs-identifier">GHC.Core</span></a></span><span>    </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.html#isOrphan"><span class="hs-identifier">isOrphan</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Instance.FunDeps.html"><span class="hs-identifier">GHC.Tc.Instance.FunDeps</span></a></span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html"><span class="hs-identifier">GHC.Tc.Utils.TcMType</span></a></span><span>
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>
</span><span id="line-62"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Multiplicity.html"><span class="hs-identifier">GHC.Core.Multiplicity</span></a></span><span>
</span><span id="line-63"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html"><span class="hs-identifier">GHC.Core.TyCo.Rep</span></a></span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Ppr.html"><span class="hs-identifier">GHC.Core.TyCo.Ppr</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Ppr.html#debugPprType"><span class="hs-identifier">debugPprType</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-65"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html"><span class="hs-identifier">GHC.Tc.Utils.TcType</span></a></span><span>
</span><span id="line-66"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html"><span class="hs-identifier">GHC.Driver.Types</span></a></span><span>
</span><span id="line-67"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Class.html"><span class="hs-identifier">GHC.Core.Class</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier">Class</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-68"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.Make.html"><span class="hs-identifier">GHC.Types.Id.Make</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Id.Make.html#mkDictFunId"><span class="hs-identifier">mkDictFunId</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-69"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.html"><span class="hs-identifier">GHC.Core</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.html#Expr"><span class="hs-identifier">Expr</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>  </span><span class="hs-comment">-- For the Coercion constructor</span><span>
</span><span id="line-70"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>
</span><span id="line-71"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.html"><span class="hs-identifier">GHC.Types.Name</span></a></span><span>
</span><span id="line-72"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span>
</span><span id="line-73"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html"><span class="hs-identifier">GHC.Core.DataCon</span></a></span><span>
</span><span id="line-74"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-75"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.html"><span class="hs-identifier">GHC.Builtin.Names</span></a></span><span>
</span><span id="line-76"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html"><span class="hs-identifier">GHC.Types.SrcLoc</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">SrcLoc</span></span><span>
</span><span id="line-77"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-78"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-79"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-80"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TypeOrKind"><span class="hs-identifier">TypeOrKind</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-81"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.LanguageExtensions.html#"><span class="hs-identifier">GHC.LanguageExtensions</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">LangExt</span></span><span>
</span><span id="line-82"></span><span>
</span><span id="line-83"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#sortBy"><span class="hs-identifier">sortBy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier">mapAccumL</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-84"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier">unless</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-85"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Function.html#"><span class="hs-identifier">Data.Function</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.Function.html#on"><span class="hs-identifier">on</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-86"></span><span>
</span><span id="line-87"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                Creating and emittind constraints
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-94"></span><span>
</span><span id="line-95"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#newMethodFromName"><span class="hs-identifier hs-type">newMethodFromName</span></a></span><span>
</span><span id="line-96"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span>              </span><span class="hs-comment">-- ^ why do we need this?</span><span>
</span><span id="line-97"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>                  </span><span class="hs-comment">-- ^ name of the method</span><span>
</span><span id="line-98"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcRhoType"><span class="hs-identifier hs-type">TcRhoType</span></a></span><span class="hs-special">]</span><span>           </span><span class="hs-comment">-- ^ types with which to instantiate the class</span><span>
</span><span id="line-99"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-100"></span><span class="hs-comment">-- ^ Used when 'Name' is the wired-in name for a wired-in class method,</span><span>
</span><span id="line-101"></span><span class="hs-comment">-- so the caller knows its type for sure, which should be of form</span><span>
</span><span id="line-102"></span><span class="hs-comment">--</span><span>
</span><span id="line-103"></span><span class="hs-comment">-- &gt; forall a. C a =&gt; &lt;blah&gt;</span><span>
</span><span id="line-104"></span><span class="hs-comment">--</span><span>
</span><span id="line-105"></span><span class="hs-comment">-- 'newMethodFromName' is supposed to instantiate just the outer</span><span>
</span><span id="line-106"></span><span class="hs-comment">-- type variable and constraint</span><span>
</span><span id="line-107"></span><span>
</span><span id="line-108"></span><span id="newMethodFromName"><span class="annot"><span class="annottext">newMethodFromName :: CtOrigin -&gt; Name -&gt; ThetaType -&gt; TcM (HsExpr GhcTc)
</span><a href="GHC.Tc.Utils.Instantiate.html#newMethodFromName"><span class="hs-identifier hs-var hs-var">newMethodFromName</span></a></span></span><span> </span><span id="local-6989586621681091856"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091856"><span class="hs-identifier hs-var">origin</span></a></span></span><span> </span><span id="local-6989586621681091855"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681091855"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621681091854"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091854"><span class="hs-identifier hs-var">ty_args</span></a></span></span><span>
</span><span id="line-109"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681091853"><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091853"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM DFunId
</span><a href="GHC.Tc.Utils.Env.html#tcLookupId"><span class="hs-identifier hs-var">tcLookupId</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681091855"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-110"></span><span>              </span><span class="hs-comment">-- Use tcLookupId not tcLookupGlobalId; the method is almost</span><span>
</span><span id="line-111"></span><span>              </span><span class="hs-comment">-- always a class op, but with -XRebindableSyntax GHC is</span><span>
</span><span id="line-112"></span><span>              </span><span class="hs-comment">-- meant to find whatever thing is in scope, and that may</span><span>
</span><span id="line-113"></span><span>              </span><span class="hs-comment">-- be an ordinary function.</span><span>
</span><span id="line-114"></span><span>
</span><span id="line-115"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681091850"><span class="annot"><span class="annottext">ty :: Type
</span><a href="#local-6989586621681091850"><span class="hs-identifier hs-var hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; ThetaType -&gt; Type
Type -&gt; ThetaType -&gt; Type
</span><a href="GHC.Core.Type.html#piResultTys"><span class="hs-identifier hs-var">piResultTys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DFunId -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091853"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091854"><span class="hs-identifier hs-var">ty_args</span></a></span><span>
</span><span id="line-116"></span><span>             </span><span class="hs-special">(</span><span id="local-6989586621681091847"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091847"><span class="hs-identifier hs-var">theta</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091846"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091846"><span class="hs-identifier hs-var">_caller_knows_this</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; (ThetaType, Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitPhiTy"><span class="hs-identifier hs-var">tcSplitPhiTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091850"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-117"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681091844"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681091844"><span class="hs-identifier hs-var">wrap</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">not</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">isForAllTy</span><span> </span><span class="hs-identifier">ty</span><span class="hs-special">)</span><span> </span><span class="hs-operator">&amp;&amp;</span><span> </span><span class="hs-identifier">isSingleton</span><span> </span><span class="hs-identifier">theta</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-118"></span><span>                 </span><span class="annot"><span class="annottext">CtOrigin
-&gt; ThetaType
-&gt; ThetaType
-&gt; IOEnv (Env TcGblEnv TcLclEnv) HsWrapper
</span><a href="GHC.Tc.Utils.Instantiate.html#instCall"><span class="hs-identifier hs-var">instCall</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091856"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091854"><span class="hs-identifier hs-var">ty_args</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091847"><span class="hs-identifier hs-var">theta</span></a></span><span>
</span><span id="line-119"></span><span>
</span><span id="line-120"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HsExpr GhcTc -&gt; TcM (HsExpr GhcTc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper -&gt; HsExpr GhcTc -&gt; HsExpr GhcTc
</span><a href="GHC.Hs.Utils.html#mkHsWrap"><span class="hs-identifier hs-var">mkHsWrap</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681091844"><span class="hs-identifier hs-var">wrap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XVar GhcTc -&gt; Located (IdP GhcTc) -&gt; HsExpr GhcTc
forall p. XVar p -&gt; Located (IdP p) -&gt; HsExpr p
</span><a href="GHC.Hs.Expr.html#HsVar"><span class="hs-identifier hs-var">HsVar</span></a></span><span> </span><span class="annot"><span class="annottext">NoExtField
XVar GhcTc
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DFunId -&gt; Located DFunId
forall e. e -&gt; Located e
</span><a href="GHC.Types.SrcLoc.html#noLoc"><span class="hs-identifier hs-var">noLoc</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091853"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-121"></span><span>
</span><span id="line-122"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
         Instantiation and skolemisation
*                                                                      *
************************************************************************

Note [Skolemisation]
~~~~~~~~~~~~~~~~~~~~
topSkolemise decomposes and skolemises a type, returning a type
with no top level foralls or (=&gt;)

Examples:

  topSkolemise (forall a. Ord a =&gt; a -&gt; a)
    =  ( wp, [a], [d:Ord a], a-&gt;a )
    where wp = /\a. \(d:Ord a). &lt;hole&gt; a d

  topSkolemise  (forall a. Ord a =&gt; forall b. Eq b =&gt; a-&gt;b-&gt;b)
    =  ( wp, [a,b], [d1:Ord a,d2:Eq b], a-&gt;b-&gt;b )
    where wp = /\a.\(d1:Ord a)./\b.\(d2:Ord b). &lt;hole&gt; a d1 b d2

This second example is the reason for the recursive 'go'
function in topSkolemise: we must remove successive layers
of foralls and (=&gt;).

In general,
  if      topSkolemise ty = (wrap, tvs, evs, rho)
    and   e :: rho
  then    wrap e :: ty
    and   'wrap' binds {tvs, evs}

-}</span><span>
</span><span id="line-155"></span><span>
</span><span id="line-156"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#topSkolemise"><span class="hs-identifier hs-type">topSkolemise</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span>
</span><span id="line-157"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span>
</span><span id="line-158"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>     </span><span class="hs-comment">-- All skolemised variables</span><span>
</span><span id="line-159"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span class="hs-special">]</span><span>            </span><span class="hs-comment">-- All &quot;given&quot;s</span><span>
</span><span id="line-160"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcRhoType"><span class="hs-identifier hs-type">TcRhoType</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-161"></span><span class="hs-comment">-- See Note [Skolemisation]</span><span>
</span><span id="line-162"></span><span id="topSkolemise"><span class="annot"><span class="annottext">topSkolemise :: Type -&gt; TcM (HsWrapper, [(Name, DFunId)], [DFunId], Type)
</span><a href="GHC.Tc.Utils.Instantiate.html#topSkolemise"><span class="hs-identifier hs-var hs-var">topSkolemise</span></a></span></span><span> </span><span id="local-6989586621681091830"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091830"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-163"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst
-&gt; HsWrapper
-&gt; [(Name, DFunId)]
-&gt; [DFunId]
-&gt; Type
-&gt; TcM (HsWrapper, [(Name, DFunId)], [DFunId], Type)
</span><a href="#local-6989586621681091829"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091828"><span class="hs-identifier hs-var">init_subst</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#idHsWrapper"><span class="hs-identifier hs-var">idHsWrapper</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091830"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-164"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-165"></span><span>    </span><span id="local-6989586621681091828"><span class="annot"><span class="annottext">init_subst :: TCvSubst
</span><a href="#local-6989586621681091828"><span class="hs-identifier hs-var hs-var">init_subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkEmptyTCvSubst"><span class="hs-identifier hs-var">mkEmptyTCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091830"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-166"></span><span>
</span><span id="line-167"></span><span>    </span><span class="hs-comment">-- Why recursive?  See Note [Skolemisation]</span><span>
</span><span id="line-168"></span><span>    </span><span id="local-6989586621681091829"><span class="annot"><span class="annottext">go :: TCvSubst
-&gt; HsWrapper
-&gt; [(Name, DFunId)]
-&gt; [DFunId]
-&gt; Type
-&gt; TcM (HsWrapper, [(Name, DFunId)], [DFunId], Type)
</span><a href="#local-6989586621681091829"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681091814"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091814"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621681091813"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681091813"><span class="hs-identifier hs-var">wrap</span></a></span></span><span> </span><span id="local-6989586621681091812"><span class="annot"><span class="annottext">[(Name, DFunId)]
</span><a href="#local-6989586621681091812"><span class="hs-identifier hs-var">tv_prs</span></a></span></span><span> </span><span id="local-6989586621681091811"><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091811"><span class="hs-identifier hs-var">ev_vars</span></a></span></span><span> </span><span id="local-6989586621681091810"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091810"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-169"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091809"><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091809"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091808"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091808"><span class="hs-identifier hs-var">theta</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091807"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091807"><span class="hs-identifier hs-var">inner_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([DFunId], ThetaType, Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitSigmaTy"><span class="hs-identifier hs-var">tcSplitSigmaTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091810"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-170"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[DFunId] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091809"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">ThetaType -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091808"><span class="hs-identifier hs-var">theta</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-171"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091804"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091804"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091803"><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091803"><span class="hs-identifier hs-var">tvs1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstSkolTyVarsX"><span class="hs-identifier hs-var">tcInstSkolTyVarsX</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091814"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091809"><span class="hs-identifier hs-var">tvs</span></a></span><span>
</span><span id="line-172"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681091802"><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091802"><span class="hs-identifier hs-var">ev_vars1</span></a></span></span><span>       </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ThetaType -&gt; TcM [DFunId]
</span><a href="GHC.Tc.Utils.TcMType.html#newEvVars"><span class="hs-identifier hs-var">newEvVars</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; ThetaType -&gt; ThetaType
TCvSubst -&gt; ThetaType -&gt; ThetaType
</span><a href="GHC.Core.TyCo.Subst.html#substTheta"><span class="hs-identifier hs-var">substTheta</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091804"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091808"><span class="hs-identifier hs-var">theta</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-173"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TCvSubst
-&gt; HsWrapper
-&gt; [(Name, DFunId)]
-&gt; [DFunId]
-&gt; Type
-&gt; TcM (HsWrapper, [(Name, DFunId)], [DFunId], Type)
</span><a href="#local-6989586621681091829"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091804"><span class="hs-identifier hs-var">subst'</span></a></span><span>
</span><span id="line-174"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681091813"><span class="hs-identifier hs-var">wrap</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; HsWrapper -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#%3C.%3E"><span class="hs-operator hs-var">&lt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId] -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpTyLams"><span class="hs-identifier hs-var">mkWpTyLams</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091803"><span class="hs-identifier hs-var">tvs1</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; HsWrapper -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#%3C.%3E"><span class="hs-operator hs-var">&lt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId] -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpLams"><span class="hs-identifier hs-var">mkWpLams</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091802"><span class="hs-identifier hs-var">ev_vars1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-175"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Name, DFunId)]
</span><a href="#local-6989586621681091812"><span class="hs-identifier hs-var">tv_prs</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, DFunId)] -&gt; [(Name, DFunId)] -&gt; [(Name, DFunId)]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(DFunId -&gt; Name) -&gt; [DFunId] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId -&gt; Name
</span><a href="GHC.Types.Var.html#tyVarName"><span class="hs-identifier hs-var">tyVarName</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091809"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Name] -&gt; [DFunId] -&gt; [(Name, DFunId)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091803"><span class="hs-identifier hs-var">tvs1</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-176"></span><span>                </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091811"><span class="hs-identifier hs-var">ev_vars</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId] -&gt; [DFunId] -&gt; [DFunId]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091802"><span class="hs-identifier hs-var">ev_vars1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-177"></span><span>                </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091807"><span class="hs-identifier hs-var">inner_ty</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-178"></span><span>
</span><span id="line-179"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-180"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(HsWrapper, [(Name, DFunId)], [DFunId], Type)
-&gt; TcM (HsWrapper, [(Name, DFunId)], [DFunId], Type)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681091813"><span class="hs-identifier hs-var">wrap</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(Name, DFunId)]
</span><a href="#local-6989586621681091812"><span class="hs-identifier hs-var">tv_prs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091811"><span class="hs-identifier hs-var">ev_vars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091814"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091810"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-181"></span><span>        </span><span class="hs-comment">-- substTy is a quick no-op on an empty substitution</span><span>
</span><span id="line-182"></span><span>
</span><span id="line-183"></span><span class="hs-comment">-- | Instantiate all outer type variables</span><span>
</span><span id="line-184"></span><span class="hs-comment">-- and any context. Never looks through arrows.</span><span>
</span><span id="line-185"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#topInstantiate"><span class="hs-identifier hs-type">topInstantiate</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcRhoType"><span class="hs-identifier hs-type">TcRhoType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-186"></span><span class="hs-comment">-- if    topInstantiate ty = (wrap, rho)</span><span>
</span><span id="line-187"></span><span class="hs-comment">-- and   e :: ty</span><span>
</span><span id="line-188"></span><span class="hs-comment">-- then  wrap e :: rho  (that is, wrap :: ty &quot;-&gt;&quot; rho)</span><span>
</span><span id="line-189"></span><span class="hs-comment">-- NB: always returns a rho-type, with no top-level forall or (=&gt;)</span><span>
</span><span id="line-190"></span><span id="topInstantiate"><span class="annot"><span class="annottext">topInstantiate :: CtOrigin -&gt; Type -&gt; TcM (HsWrapper, Type)
</span><a href="GHC.Tc.Utils.Instantiate.html#topInstantiate"><span class="hs-identifier hs-var hs-var">topInstantiate</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; CtOrigin -&gt; Type -&gt; TcM (HsWrapper, Type)
</span><a href="GHC.Tc.Utils.Instantiate.html#top_instantiate"><span class="hs-identifier hs-var">top_instantiate</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-191"></span><span>
</span><span id="line-192"></span><span class="hs-comment">-- | Instantiate all outer 'Inferred' binders</span><span>
</span><span id="line-193"></span><span class="hs-comment">-- and any context. Never looks through arrows or specified type variables.</span><span>
</span><span id="line-194"></span><span class="hs-comment">-- Used for visible type application.</span><span>
</span><span id="line-195"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#topInstantiateInferred"><span class="hs-identifier hs-type">topInstantiateInferred</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span>
</span><span id="line-196"></span><span>                       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-197"></span><span class="hs-comment">-- if    topInstantiate ty = (wrap, rho)</span><span>
</span><span id="line-198"></span><span class="hs-comment">-- and   e :: ty</span><span>
</span><span id="line-199"></span><span class="hs-comment">-- then  wrap e :: rho</span><span>
</span><span id="line-200"></span><span class="hs-comment">-- NB: may return a sigma-type</span><span>
</span><span id="line-201"></span><span id="topInstantiateInferred"><span class="annot"><span class="annottext">topInstantiateInferred :: CtOrigin -&gt; Type -&gt; TcM (HsWrapper, Type)
</span><a href="GHC.Tc.Utils.Instantiate.html#topInstantiateInferred"><span class="hs-identifier hs-var hs-var">topInstantiateInferred</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; CtOrigin -&gt; Type -&gt; TcM (HsWrapper, Type)
</span><a href="GHC.Tc.Utils.Instantiate.html#top_instantiate"><span class="hs-identifier hs-var">top_instantiate</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-202"></span><span>
</span><span id="line-203"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#top_instantiate"><span class="hs-identifier hs-type">top_instantiate</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>   </span><span class="hs-comment">-- True  &lt;=&gt; instantiate *all* variables</span><span>
</span><span id="line-204"></span><span>                          </span><span class="hs-comment">-- False &lt;=&gt; instantiate only the inferred ones</span><span>
</span><span id="line-205"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcSigmaType"><span class="hs-identifier hs-type">TcSigmaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcRhoType"><span class="hs-identifier hs-type">TcRhoType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-206"></span><span id="top_instantiate"><span class="annot"><span class="annottext">top_instantiate :: Bool -&gt; CtOrigin -&gt; Type -&gt; TcM (HsWrapper, Type)
</span><a href="GHC.Tc.Utils.Instantiate.html#top_instantiate"><span class="hs-identifier hs-var hs-var">top_instantiate</span></a></span></span><span> </span><span id="local-6989586621681091793"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681091793"><span class="hs-identifier hs-var">inst_all</span></a></span></span><span> </span><span id="local-6989586621681091792"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091792"><span class="hs-identifier hs-var">orig</span></a></span></span><span> </span><span id="local-6989586621681091791"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091791"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-207"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091790"><span class="annot"><span class="annottext">[VarBndr DFunId ArgFlag]
</span><a href="#local-6989586621681091790"><span class="hs-identifier hs-var">binders</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091789"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091789"><span class="hs-identifier hs-var">phi</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([VarBndr DFunId ArgFlag], Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitForAllVarBndrs"><span class="hs-identifier hs-var">tcSplitForAllVarBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091791"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-208"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091787"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091787"><span class="hs-identifier hs-var">theta</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091786"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091786"><span class="hs-identifier hs-var">rho</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; (ThetaType, Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitPhiTy"><span class="hs-identifier hs-var">tcSplitPhiTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091789"><span class="hs-identifier hs-var">phi</span></a></span><span>
</span><span id="line-209"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[VarBndr DFunId ArgFlag] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[VarBndr DFunId ArgFlag]
</span><a href="#local-6989586621681091790"><span class="hs-identifier hs-var">binders</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">ThetaType -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091787"><span class="hs-identifier hs-var">theta</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-210"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091785"><span class="annot"><span class="annottext">[VarBndr DFunId ArgFlag]
</span><a href="#local-6989586621681091785"><span class="hs-identifier hs-var">inst_bndrs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091784"><span class="annot"><span class="annottext">[VarBndr DFunId ArgFlag]
</span><a href="#local-6989586621681091784"><span class="hs-identifier hs-var">leave_bndrs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(VarBndr DFunId ArgFlag -&gt; Bool)
-&gt; [VarBndr DFunId ArgFlag]
-&gt; ([VarBndr DFunId ArgFlag], [VarBndr DFunId ArgFlag])
forall a. (a -&gt; Bool) -&gt; [a] -&gt; ([a], [a])
</span><a href="../../base/src/GHC.List.html#span"><span class="hs-identifier hs-var">span</span></a></span><span> </span><span class="annot"><span class="annottext">VarBndr DFunId ArgFlag -&gt; Bool
forall {tv}. VarBndr tv ArgFlag -&gt; Bool
</span><a href="#local-6989586621681091782"><span class="hs-identifier hs-var">should_inst</span></a></span><span> </span><span class="annot"><span class="annottext">[VarBndr DFunId ArgFlag]
</span><a href="#local-6989586621681091790"><span class="hs-identifier hs-var">binders</span></a></span><span>
</span><span id="line-211"></span><span>             </span><span class="hs-special">(</span><span id="local-6989586621681091780"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091780"><span class="hs-identifier hs-var">inst_theta</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091779"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091779"><span class="hs-identifier hs-var">leave_theta</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-212"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[VarBndr DFunId ArgFlag] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[VarBndr DFunId ArgFlag]
</span><a href="#local-6989586621681091784"><span class="hs-identifier hs-var">leave_bndrs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091787"><span class="hs-identifier hs-var">theta</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-213"></span><span>               </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091787"><span class="hs-identifier hs-var">theta</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-214"></span><span>             </span><span id="local-6989586621681091778"><span class="annot"><span class="annottext">in_scope :: InScopeSet
</span><a href="#local-6989586621681091778"><span class="hs-identifier hs-var hs-var">in_scope</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091791"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-215"></span><span>             </span><span id="local-6989586621681091777"><span class="annot"><span class="annottext">empty_subst :: TCvSubst
</span><a href="#local-6989586621681091777"><span class="hs-identifier hs-var hs-var">empty_subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkEmptyTCvSubst"><span class="hs-identifier hs-var">mkEmptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621681091778"><span class="hs-identifier hs-var">in_scope</span></a></span><span>
</span><span id="line-216"></span><span>             </span><span id="local-6989586621681091776"><span class="annot"><span class="annottext">inst_tvs :: [DFunId]
</span><a href="#local-6989586621681091776"><span class="hs-identifier hs-var hs-var">inst_tvs</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[VarBndr DFunId ArgFlag] -&gt; [DFunId]
forall tv argf. [VarBndr tv argf] -&gt; [tv]
</span><a href="GHC.Types.Var.html#binderVars"><span class="hs-identifier hs-var">binderVars</span></a></span><span> </span><span class="annot"><span class="annottext">[VarBndr DFunId ArgFlag]
</span><a href="#local-6989586621681091785"><span class="hs-identifier hs-var">inst_bndrs</span></a></span><span>
</span><span id="line-217"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091774"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091774"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091773"><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091773"><span class="hs-identifier hs-var">inst_tvs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TCvSubst
 -&gt; DFunId -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, DFunId))
-&gt; TCvSubst -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
forall (m :: * -&gt; *) acc x y.
Monad m =&gt;
(acc -&gt; x -&gt; m (acc, y)) -&gt; acc -&gt; [x] -&gt; m (acc, [y])
</span><a href="GHC.Utils.Monad.html#mapAccumLM"><span class="hs-identifier hs-var">mapAccumLM</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
-&gt; DFunId -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, DFunId)
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarX"><span class="hs-identifier hs-var">newMetaTyVarX</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091777"><span class="hs-identifier hs-var">empty_subst</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091776"><span class="hs-identifier hs-var">inst_tvs</span></a></span><span>
</span><span id="line-218"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681091768"><span class="annot"><span class="annottext">inst_theta' :: ThetaType
</span><a href="#local-6989586621681091768"><span class="hs-identifier hs-var hs-var">inst_theta'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; ThetaType -&gt; ThetaType
TCvSubst -&gt; ThetaType -&gt; ThetaType
</span><a href="GHC.Core.TyCo.Subst.html#substTheta"><span class="hs-identifier hs-var">substTheta</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091774"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091780"><span class="hs-identifier hs-var">inst_theta</span></a></span><span>
</span><span id="line-219"></span><span>             </span><span id="local-6989586621681091765"><span class="annot"><span class="annottext">sigma' :: Type
</span><a href="#local-6989586621681091765"><span class="hs-identifier hs-var hs-var">sigma'</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091774"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[VarBndr DFunId ArgFlag] -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkForAllTys"><span class="hs-identifier hs-var">mkForAllTys</span></a></span><span> </span><span class="annot"><span class="annottext">[VarBndr DFunId ArgFlag]
</span><a href="#local-6989586621681091784"><span class="hs-identifier hs-var">leave_bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Type) -&gt; Type -&gt; Type
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-220"></span><span>                                          </span><span class="annot"><span class="annottext">ThetaType -&gt; Type -&gt; Type
</span><a href="GHC.Tc.Utils.TcType.html#mkPhiTy"><span class="hs-identifier hs-var">mkPhiTy</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091779"><span class="hs-identifier hs-var">leave_theta</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091786"><span class="hs-identifier hs-var">rho</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-221"></span><span>             </span><span id="local-6989586621681091762"><span class="annot"><span class="annottext">inst_tv_tys' :: ThetaType
</span><a href="#local-6989586621681091762"><span class="hs-identifier hs-var hs-var">inst_tv_tys'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[DFunId] -&gt; ThetaType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTys"><span class="hs-identifier hs-var">mkTyVarTys</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091773"><span class="hs-identifier hs-var">inst_tvs'</span></a></span><span>
</span><span id="line-222"></span><span>
</span><span id="line-223"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681091760"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681091760"><span class="hs-identifier hs-var">wrap1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin
-&gt; ThetaType
-&gt; ThetaType
-&gt; IOEnv (Env TcGblEnv TcLclEnv) HsWrapper
</span><a href="GHC.Tc.Utils.Instantiate.html#instCall"><span class="hs-identifier hs-var">instCall</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091792"><span class="hs-identifier hs-var">orig</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091762"><span class="hs-identifier hs-var">inst_tv_tys'</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091768"><span class="hs-identifier hs-var">inst_theta'</span></a></span><span>
</span><span id="line-224"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Instantiating&quot;</span></span><span>
</span><span id="line-225"></span><span>                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;all tyvars?&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681091793"><span class="hs-identifier hs-var">inst_all</span></a></span><span>
</span><span id="line-226"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;origin&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; SDoc
</span><a href="GHC.Tc.Types.Origin.html#pprCtOrigin"><span class="hs-identifier hs-var">pprCtOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091792"><span class="hs-identifier hs-var">orig</span></a></span><span>
</span><span id="line-227"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;type&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#debugPprType"><span class="hs-identifier hs-var">debugPprType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091791"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-228"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;theta&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091787"><span class="hs-identifier hs-var">theta</span></a></span><span>
</span><span id="line-229"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;leave_bndrs&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[VarBndr DFunId ArgFlag] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[VarBndr DFunId ArgFlag]
</span><a href="#local-6989586621681091784"><span class="hs-identifier hs-var">leave_bndrs</span></a></span><span>
</span><span id="line-230"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;with&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Type -&gt; SDoc) -&gt; ThetaType -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#debugPprType"><span class="hs-identifier hs-var">debugPprType</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091762"><span class="hs-identifier hs-var">inst_tv_tys'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-231"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;theta:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>  </span><span class="annot"><span class="annottext">ThetaType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091768"><span class="hs-identifier hs-var">inst_theta'</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-232"></span><span>
</span><span id="line-233"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091753"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681091753"><span class="hs-identifier hs-var">wrap2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091752"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091752"><span class="hs-identifier hs-var">rho2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span>
</span><span id="line-234"></span><span>           </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">[VarBndr DFunId ArgFlag] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[VarBndr DFunId ArgFlag]
</span><a href="#local-6989586621681091784"><span class="hs-identifier hs-var">leave_bndrs</span></a></span><span>   </span><span class="hs-comment">-- NB: if inst_all is True then leave_bndrs = []</span><span>
</span><span id="line-235"></span><span>
</span><span id="line-236"></span><span>         </span><span class="hs-comment">-- account for types like forall a. Num a =&gt; forall b. Ord b =&gt; ...</span><span>
</span><span id="line-237"></span><span>           </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; CtOrigin -&gt; Type -&gt; TcM (HsWrapper, Type)
</span><a href="GHC.Tc.Utils.Instantiate.html#top_instantiate"><span class="hs-identifier hs-var">top_instantiate</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681091793"><span class="hs-identifier hs-var">inst_all</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091792"><span class="hs-identifier hs-var">orig</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091765"><span class="hs-identifier hs-var">sigma'</span></a></span><span>
</span><span id="line-238"></span><span>
</span><span id="line-239"></span><span>         </span><span class="hs-comment">-- but don't loop if there were any un-inst'able tyvars</span><span>
</span><span id="line-240"></span><span>           </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">(HsWrapper, Type) -&gt; TcM (HsWrapper, Type)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#idHsWrapper"><span class="hs-identifier hs-var">idHsWrapper</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091765"><span class="hs-identifier hs-var">sigma'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-241"></span><span>
</span><span id="line-242"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(HsWrapper, Type) -&gt; TcM (HsWrapper, Type)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681091753"><span class="hs-identifier hs-var">wrap2</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; HsWrapper -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#%3C.%3E"><span class="hs-operator hs-var">&lt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681091760"><span class="hs-identifier hs-var">wrap1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091752"><span class="hs-identifier hs-var">rho2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-243"></span><span>
</span><span id="line-244"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(HsWrapper, Type) -&gt; TcM (HsWrapper, Type)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#idHsWrapper"><span class="hs-identifier hs-var">idHsWrapper</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091791"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-245"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-246"></span><span>
</span><span id="line-247"></span><span>    </span><span id="local-6989586621681091782"><span class="annot"><span class="annottext">should_inst :: VarBndr tv ArgFlag -&gt; Bool
</span><a href="#local-6989586621681091782"><span class="hs-identifier hs-var hs-var">should_inst</span></a></span></span><span> </span><span id="local-6989586621681091749"><span class="annot"><span class="annottext">VarBndr tv ArgFlag
</span><a href="#local-6989586621681091749"><span class="hs-identifier hs-var">bndr</span></a></span></span><span>
</span><span id="line-248"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681091793"><span class="hs-identifier hs-var">inst_all</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-249"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarBndr tv ArgFlag -&gt; ArgFlag
forall tv argf. VarBndr tv argf -&gt; argf
</span><a href="GHC.Types.Var.html#binderArgFlag"><span class="hs-identifier hs-var">binderArgFlag</span></a></span><span> </span><span class="annot"><span class="annottext">VarBndr tv ArgFlag
</span><a href="#local-6989586621681091749"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">ArgFlag -&gt; ArgFlag -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">ArgFlag
</span><a href="GHC.Types.Var.html#Inferred"><span class="hs-identifier hs-var">Inferred</span></a></span><span>
</span><span id="line-250"></span><span>
</span><span id="line-251"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#instTyVarsWith"><span class="hs-identifier hs-type">instTyVarsWith</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span>
</span><span id="line-252"></span><span class="hs-comment">-- Use this when you want to instantiate (forall a b c. ty) with</span><span>
</span><span id="line-253"></span><span class="hs-comment">-- types [ta, tb, tc], but when the kinds of 'a' and 'ta' might</span><span>
</span><span id="line-254"></span><span class="hs-comment">-- not yet match (perhaps because there are unsolved constraints; #14154)</span><span>
</span><span id="line-255"></span><span class="hs-comment">-- If they don't match, emit a kind-equality to promise that they will</span><span>
</span><span id="line-256"></span><span class="hs-comment">-- eventually do so, and thus make a kind-homongeneous substitution.</span><span>
</span><span id="line-257"></span><span id="instTyVarsWith"><span class="annot"><span class="annottext">instTyVarsWith :: CtOrigin -&gt; [DFunId] -&gt; ThetaType -&gt; TcM TCvSubst
</span><a href="GHC.Tc.Utils.Instantiate.html#instTyVarsWith"><span class="hs-identifier hs-var hs-var">instTyVarsWith</span></a></span></span><span> </span><span id="local-6989586621681091745"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091745"><span class="hs-identifier hs-var">orig</span></a></span></span><span> </span><span id="local-6989586621681091744"><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091744"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621681091743"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091743"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-258"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [DFunId] -&gt; ThetaType -&gt; TcM TCvSubst
</span><a href="#local-6989586621681091742"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#emptyTCvSubst"><span class="hs-identifier hs-var">emptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091744"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091743"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-259"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-260"></span><span>    </span><span id="local-6989586621681091742"><span class="annot"><span class="annottext">go :: TCvSubst -&gt; [DFunId] -&gt; ThetaType -&gt; TcM TCvSubst
</span><a href="#local-6989586621681091742"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681091731"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091731"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-261"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TcM TCvSubst
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091731"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-262"></span><span>    </span><span class="annot"><a href="#local-6989586621681091742"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681091730"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091730"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091729"><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091729"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681091728"><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091728"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091727"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091727"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681091726"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091726"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-263"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091725"><span class="hs-identifier hs-var">tv_kind</span></a></span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Type -&gt; Bool
Type -&gt; Type -&gt; Bool
</span><a href="GHC.Tc.Utils.TcType.html#tcEqType"><span class="hs-operator hs-var">`tcEqType`</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091723"><span class="hs-identifier hs-var">ty_kind</span></a></span><span>
</span><span id="line-264"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [DFunId] -&gt; ThetaType -&gt; TcM TCvSubst
</span><a href="#local-6989586621681091742"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; DFunId -&gt; Type -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTvSubstAndInScope"><span class="hs-identifier hs-var">extendTvSubstAndInScope</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091730"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091729"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091727"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091728"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091726"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-265"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-266"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681091721"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681091721"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; TypeOrKind -&gt; Role -&gt; Type -&gt; Type -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.TcMType.html#emitWantedEq"><span class="hs-identifier hs-var">emitWantedEq</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091745"><span class="hs-identifier hs-var">orig</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="GHC.Types.Basic.html#KindLevel"><span class="hs-identifier hs-var">KindLevel</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091723"><span class="hs-identifier hs-var">ty_kind</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091725"><span class="hs-identifier hs-var">tv_kind</span></a></span><span>
</span><span id="line-267"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [DFunId] -&gt; ThetaType -&gt; TcM TCvSubst
</span><a href="#local-6989586621681091742"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; DFunId -&gt; Type -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTvSubstAndInScope"><span class="hs-identifier hs-var">extendTvSubstAndInScope</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091730"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091729"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091727"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Coercion -&gt; Type
</span><a href="GHC.Core.Type.html#mkCastTy"><span class="hs-operator hs-var">`mkCastTy`</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681091721"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091728"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091726"><span class="hs-identifier hs-var">tys</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-268"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-269"></span><span>        </span><span id="local-6989586621681091725"><span class="annot"><span class="annottext">tv_kind :: Type
</span><a href="#local-6989586621681091725"><span class="hs-identifier hs-var hs-var">tv_kind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091730"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DFunId -&gt; Type
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091729"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-270"></span><span>        </span><span id="local-6989586621681091723"><span class="annot"><span class="annottext">ty_kind :: Type
</span><a href="#local-6989586621681091723"><span class="hs-identifier hs-var hs-var">ty_kind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Type
Type -&gt; Type
</span><a href="GHC.Core.Type.html#tcTypeKind"><span class="hs-identifier hs-var">tcTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091727"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-271"></span><span>
</span><span id="line-272"></span><span>    </span><span class="annot"><a href="#local-6989586621681091742"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM TCvSubst
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;instTysWith&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[DFunId] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091744"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091743"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-273"></span><span>
</span><span id="line-274"></span><span>
</span><span id="line-275"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
            Instantiating a call
*                                                                      *
************************************************************************

Note [Handling boxed equality]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The solver deals entirely in terms of unboxed (primitive) equality.
There should never be a boxed Wanted equality. Ever. But, what if
we are calling `foo :: forall a. (F a ~ Bool) =&gt; ...`? That equality
is boxed, so naive treatment here would emit a boxed Wanted equality.

So we simply check for this case and make the right boxing of evidence.

-}</span><span>
</span><span id="line-292"></span><span>
</span><span id="line-293"></span><span class="hs-comment">----------------</span><span>
</span><span id="line-294"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#instCall"><span class="hs-identifier hs-type">instCall</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcThetaType"><span class="hs-identifier hs-type">TcThetaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span>
</span><span id="line-295"></span><span class="hs-comment">-- Instantiate the constraints of a call</span><span>
</span><span id="line-296"></span><span class="hs-comment">--      (instCall o tys theta)</span><span>
</span><span id="line-297"></span><span class="hs-comment">-- (a) Makes fresh dictionaries as necessary for the constraints (theta)</span><span>
</span><span id="line-298"></span><span class="hs-comment">-- (b) Throws these dictionaries into the LIE</span><span>
</span><span id="line-299"></span><span class="hs-comment">-- (c) Returns an HsWrapper ([.] tys dicts)</span><span>
</span><span id="line-300"></span><span>
</span><span id="line-301"></span><span id="instCall"><span class="annot"><span class="annottext">instCall :: CtOrigin
-&gt; ThetaType
-&gt; ThetaType
-&gt; IOEnv (Env TcGblEnv TcLclEnv) HsWrapper
</span><a href="GHC.Tc.Utils.Instantiate.html#instCall"><span class="hs-identifier hs-var hs-var">instCall</span></a></span></span><span> </span><span id="local-6989586621681091708"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091708"><span class="hs-identifier hs-var">orig</span></a></span></span><span> </span><span id="local-6989586621681091707"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091707"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span id="local-6989586621681091706"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091706"><span class="hs-identifier hs-var">theta</span></a></span></span><span>
</span><span id="line-302"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681091705"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681091705"><span class="hs-identifier hs-var">dict_app</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; ThetaType -&gt; IOEnv (Env TcGblEnv TcLclEnv) HsWrapper
</span><a href="GHC.Tc.Utils.Instantiate.html#instCallConstraints"><span class="hs-identifier hs-var">instCallConstraints</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091708"><span class="hs-identifier hs-var">orig</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091706"><span class="hs-identifier hs-var">theta</span></a></span><span>
</span><span id="line-303"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; IOEnv (Env TcGblEnv TcLclEnv) HsWrapper
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681091705"><span class="hs-identifier hs-var">dict_app</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; HsWrapper -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#%3C.%3E"><span class="hs-operator hs-var">&lt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpTyApps"><span class="hs-identifier hs-var">mkWpTyApps</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091707"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-304"></span><span>
</span><span id="line-305"></span><span class="hs-comment">----------------</span><span>
</span><span id="line-306"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#instCallConstraints"><span class="hs-identifier hs-type">instCallConstraints</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcThetaType"><span class="hs-identifier hs-type">TcThetaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span>
</span><span id="line-307"></span><span class="hs-comment">-- Instantiates the TcTheta, puts all constraints thereby generated</span><span>
</span><span id="line-308"></span><span class="hs-comment">-- into the LIE, and returns a HsWrapper to enclose the call site.</span><span>
</span><span id="line-309"></span><span>
</span><span id="line-310"></span><span id="instCallConstraints"><span class="annot"><span class="annottext">instCallConstraints :: CtOrigin -&gt; ThetaType -&gt; IOEnv (Env TcGblEnv TcLclEnv) HsWrapper
</span><a href="GHC.Tc.Utils.Instantiate.html#instCallConstraints"><span class="hs-identifier hs-var hs-var">instCallConstraints</span></a></span></span><span> </span><span id="local-6989586621681091703"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091703"><span class="hs-identifier hs-var">orig</span></a></span></span><span> </span><span id="local-6989586621681091702"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091702"><span class="hs-identifier hs-var">preds</span></a></span></span><span>
</span><span id="line-311"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">ThetaType -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091702"><span class="hs-identifier hs-var">preds</span></a></span><span>
</span><span id="line-312"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; IOEnv (Env TcGblEnv TcLclEnv) HsWrapper
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#idHsWrapper"><span class="hs-identifier hs-var">idHsWrapper</span></a></span><span>
</span><span id="line-313"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-314"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681091701"><span class="annot"><span class="annottext">[EvTerm]
</span><a href="#local-6989586621681091701"><span class="hs-identifier hs-var">evs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; IOEnv (Env TcGblEnv TcLclEnv) EvTerm)
-&gt; ThetaType -&gt; IOEnv (Env TcGblEnv TcLclEnv) [EvTerm]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; IOEnv (Env TcGblEnv TcLclEnv) EvTerm
</span><a href="#local-6989586621681091699"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091702"><span class="hs-identifier hs-var">preds</span></a></span><span>
</span><span id="line-315"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;instCallConstraints&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[EvTerm] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[EvTerm]
</span><a href="#local-6989586621681091701"><span class="hs-identifier hs-var">evs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-316"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; IOEnv (Env TcGblEnv TcLclEnv) HsWrapper
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[EvTerm] -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpEvApps"><span class="hs-identifier hs-var">mkWpEvApps</span></a></span><span> </span><span class="annot"><span class="annottext">[EvTerm]
</span><a href="#local-6989586621681091701"><span class="hs-identifier hs-var">evs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-317"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-318"></span><span>    </span><span class="annot"><a href="#local-6989586621681091699"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcPredType"><span class="hs-identifier hs-type">TcPredType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#EvTerm"><span class="hs-identifier hs-type">EvTerm</span></a></span><span>
</span><span id="line-319"></span><span>    </span><span id="local-6989586621681091699"><span class="annot"><span class="annottext">go :: Type -&gt; IOEnv (Env TcGblEnv TcLclEnv) EvTerm
</span><a href="#local-6989586621681091699"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681091696"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091696"><span class="hs-identifier hs-var">pred</span></a></span></span><span>
</span><span id="line-320"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091695"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091695"><span class="hs-identifier hs-var">ty1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091694"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091694"><span class="hs-identifier hs-var">ty2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (Role, Type, Type)
</span><a href="GHC.Core.Predicate.html#getEqPredTys_maybe"><span class="hs-identifier hs-var">getEqPredTys_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091696"><span class="hs-identifier hs-var">pred</span></a></span><span> </span><span class="hs-comment">-- Try short-cut #1</span><span>
</span><span id="line-321"></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681091692"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681091692"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn) -&gt; Type -&gt; Type -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#unifyType"><span class="hs-identifier hs-var">unifyType</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091695"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091694"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-322"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">EvTerm -&gt; IOEnv (Env TcGblEnv TcLclEnv) EvTerm
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Coercion -&gt; EvTerm
</span><a href="GHC.Tc.Types.Evidence.html#evCoercion"><span class="hs-identifier hs-var">evCoercion</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681091692"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-323"></span><span>
</span><span id="line-324"></span><span>       </span><span class="hs-comment">-- Try short-cut #2</span><span>
</span><span id="line-325"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091690"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681091690"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091689"><span class="annot"><span class="annottext">args :: ThetaType
</span><a href="#local-6989586621681091689"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091688"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091688"><span class="hs-identifier hs-var">ty1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091687"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091687"><span class="hs-identifier hs-var">ty2</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (TyCon, ThetaType)
Type -&gt; Maybe (TyCon, ThetaType)
</span><a href="GHC.Core.Type.html#splitTyConApp_maybe"><span class="hs-identifier hs-var">splitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091696"><span class="hs-identifier hs-var">pred</span></a></span><span>
</span><span id="line-326"></span><span>     </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681091690"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#heqTyConKey"><span class="hs-identifier hs-var">heqTyConKey</span></a></span><span>
</span><span id="line-327"></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681091683"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681091683"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn) -&gt; Type -&gt; Type -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#unifyType"><span class="hs-identifier hs-var">unifyType</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcRn)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091688"><span class="hs-identifier hs-var">ty1</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091687"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-328"></span><span>          </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">EvTerm -&gt; IOEnv (Env TcGblEnv TcLclEnv) EvTerm
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DFunId -&gt; ThetaType -&gt; [EvExpr] -&gt; EvTerm
</span><a href="GHC.Tc.Types.Evidence.html#evDFunApp"><span class="hs-identifier hs-var">evDFunApp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; DFunId
</span><a href="GHC.Core.DataCon.html#dataConWrapId"><span class="hs-identifier hs-var">dataConWrapId</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="GHC.Builtin.Types.html#heqDataCon"><span class="hs-identifier hs-var">heqDataCon</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091689"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Coercion -&gt; EvExpr
forall b. Coercion -&gt; Expr b
</span><a href="GHC.Core.html#Coercion"><span class="hs-identifier hs-var">Coercion</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681091683"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-329"></span><span>
</span><span id="line-330"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-331"></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; Type -&gt; IOEnv (Env TcGblEnv TcLclEnv) EvTerm
</span><a href="GHC.Tc.Utils.TcMType.html#emitWanted"><span class="hs-identifier hs-var">emitWanted</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091703"><span class="hs-identifier hs-var">orig</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091696"><span class="hs-identifier hs-var">pred</span></a></span><span>
</span><span id="line-332"></span><span>
</span><span id="line-333"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#instDFunType"><span class="hs-identifier hs-type">instDFunType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#DFunId"><span class="hs-identifier hs-type">DFunId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.InstEnv.html#DFunInstType"><span class="hs-identifier hs-type">DFunInstType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-334"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span>      </span><span class="hs-comment">-- instantiated argument types</span><span>
</span><span id="line-335"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcThetaType"><span class="hs-identifier hs-type">TcThetaType</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- instantiated constraint</span><span>
</span><span id="line-336"></span><span class="hs-comment">-- See Note [DFunInstType: instantiating types] in GHC.Core.InstEnv</span><span>
</span><span id="line-337"></span><span id="instDFunType"><span class="annot"><span class="annottext">instDFunType :: DFunId -&gt; [DFunInstType] -&gt; TcM (ThetaType, ThetaType)
</span><a href="GHC.Tc.Utils.Instantiate.html#instDFunType"><span class="hs-identifier hs-var hs-var">instDFunType</span></a></span></span><span> </span><span id="local-6989586621681091678"><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091678"><span class="hs-identifier hs-var">dfun_id</span></a></span></span><span> </span><span id="local-6989586621681091677"><span class="annot"><span class="annottext">[DFunInstType]
</span><a href="#local-6989586621681091677"><span class="hs-identifier hs-var">dfun_inst_tys</span></a></span></span><span>
</span><span id="line-338"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091676"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091676"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091675"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091675"><span class="hs-identifier hs-var">inst_tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [DFunId] -&gt; [DFunInstType] -&gt; TcM (TCvSubst, ThetaType)
</span><a href="#local-6989586621681091674"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091673"><span class="hs-identifier hs-var">empty_subst</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091672"><span class="hs-identifier hs-var">dfun_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunInstType]
</span><a href="#local-6989586621681091677"><span class="hs-identifier hs-var">dfun_inst_tys</span></a></span><span>
</span><span id="line-339"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(ThetaType, ThetaType) -&gt; TcM (ThetaType, ThetaType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091675"><span class="hs-identifier hs-var">inst_tys</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; ThetaType -&gt; ThetaType
TCvSubst -&gt; ThetaType -&gt; ThetaType
</span><a href="GHC.Core.TyCo.Subst.html#substTheta"><span class="hs-identifier hs-var">substTheta</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091676"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091671"><span class="hs-identifier hs-var">dfun_theta</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-340"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-341"></span><span>    </span><span id="local-6989586621681091670"><span class="annot"><span class="annottext">dfun_ty :: Type
</span><a href="#local-6989586621681091670"><span class="hs-identifier hs-var hs-var">dfun_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DFunId -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091678"><span class="hs-identifier hs-var">dfun_id</span></a></span><span>
</span><span id="line-342"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681091672"><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091672"><span class="hs-identifier hs-var">dfun_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091671"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091671"><span class="hs-identifier hs-var">dfun_theta</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([DFunId], ThetaType, Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitSigmaTy"><span class="hs-identifier hs-var">tcSplitSigmaTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091670"><span class="hs-identifier hs-var">dfun_ty</span></a></span><span>
</span><span id="line-343"></span><span>    </span><span id="local-6989586621681091673"><span class="annot"><span class="annottext">empty_subst :: TCvSubst
</span><a href="#local-6989586621681091673"><span class="hs-identifier hs-var hs-var">empty_subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkEmptyTCvSubst"><span class="hs-identifier hs-var">mkEmptyTCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091670"><span class="hs-identifier hs-var">dfun_ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-344"></span><span>                  </span><span class="hs-comment">-- With quantified constraints, the</span><span>
</span><span id="line-345"></span><span>                  </span><span class="hs-comment">-- type of a dfun may not be closed</span><span>
</span><span id="line-346"></span><span>
</span><span id="line-347"></span><span>    </span><span class="annot"><a href="#local-6989586621681091674"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.InstEnv.html#DFunInstType"><span class="hs-identifier hs-type">DFunInstType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-348"></span><span>    </span><span id="local-6989586621681091674"><span class="annot"><span class="annottext">go :: TCvSubst -&gt; [DFunId] -&gt; [DFunInstType] -&gt; TcM (TCvSubst, ThetaType)
</span><a href="#local-6989586621681091674"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681091669"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091669"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TCvSubst, ThetaType) -&gt; TcM (TCvSubst, ThetaType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091669"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-349"></span><span>    </span><span class="annot"><a href="#local-6989586621681091674"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681091668"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091668"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091667"><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091667"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681091666"><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091666"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681091665"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091665"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681091664"><span class="annot"><span class="annottext">[DFunInstType]
</span><a href="#local-6989586621681091664"><span class="hs-identifier hs-var">mb_tys</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-350"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091663"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091663"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091662"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091662"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [DFunId] -&gt; [DFunInstType] -&gt; TcM (TCvSubst, ThetaType)
</span><a href="#local-6989586621681091674"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; DFunId -&gt; Type -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTvSubstAndInScope"><span class="hs-identifier hs-var">extendTvSubstAndInScope</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091668"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091667"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091665"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-351"></span><span>                                 </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091666"><span class="hs-identifier hs-var">tvs</span></a></span><span>
</span><span id="line-352"></span><span>                                 </span><span class="annot"><span class="annottext">[DFunInstType]
</span><a href="#local-6989586621681091664"><span class="hs-identifier hs-var">mb_tys</span></a></span><span>
</span><span id="line-353"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TCvSubst, ThetaType) -&gt; TcM (TCvSubst, ThetaType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091663"><span class="hs-identifier hs-var">subst'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091665"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; ThetaType -&gt; ThetaType
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091662"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-354"></span><span>    </span><span class="annot"><a href="#local-6989586621681091674"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681091661"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091661"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091660"><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091660"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681091659"><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091659"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DFunInstType
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span> </span><span id="local-6989586621681091658"><span class="annot"><span class="annottext">[DFunInstType]
</span><a href="#local-6989586621681091658"><span class="hs-identifier hs-var">mb_tys</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-355"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091657"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091657"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091656"><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091656"><span class="hs-identifier hs-var">tv'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TCvSubst
-&gt; DFunId -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, DFunId)
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarX"><span class="hs-identifier hs-var">newMetaTyVarX</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091661"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091660"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-356"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091655"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091655"><span class="hs-identifier hs-var">subst''</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091654"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091654"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [DFunId] -&gt; [DFunInstType] -&gt; TcM (TCvSubst, ThetaType)
</span><a href="#local-6989586621681091674"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091657"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091659"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunInstType]
</span><a href="#local-6989586621681091658"><span class="hs-identifier hs-var">mb_tys</span></a></span><span>
</span><span id="line-357"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TCvSubst, ThetaType) -&gt; TcM (TCvSubst, ThetaType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091655"><span class="hs-identifier hs-var">subst''</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">DFunId -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091656"><span class="hs-identifier hs-var">tv'</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; ThetaType -&gt; ThetaType
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091654"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-358"></span><span>    </span><span class="annot"><a href="#local-6989586621681091674"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">[DFunInstType]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM (TCvSubst, ThetaType)
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;instDFunTypes&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DFunId -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091678"><span class="hs-identifier hs-var">dfun_id</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunInstType] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunInstType]
</span><a href="#local-6989586621681091677"><span class="hs-identifier hs-var">dfun_inst_tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-359"></span><span>
</span><span id="line-360"></span><span class="hs-comment">----------------</span><span>
</span><span id="line-361"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#instStupidTheta"><span class="hs-identifier hs-type">instStupidTheta</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcThetaType"><span class="hs-identifier hs-type">TcThetaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-362"></span><span class="hs-comment">-- Similar to instCall, but only emit the constraints in the LIE</span><span>
</span><span id="line-363"></span><span class="hs-comment">-- Used exclusively for the 'stupid theta' of a data constructor</span><span>
</span><span id="line-364"></span><span id="instStupidTheta"><span class="annot"><span class="annottext">instStupidTheta :: CtOrigin -&gt; ThetaType -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Instantiate.html#instStupidTheta"><span class="hs-identifier hs-var hs-var">instStupidTheta</span></a></span></span><span> </span><span id="local-6989586621681091652"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091652"><span class="hs-identifier hs-var">orig</span></a></span></span><span> </span><span id="local-6989586621681091651"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091651"><span class="hs-identifier hs-var">theta</span></a></span></span><span>
</span><span id="line-365"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681091650"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681091650"><span class="hs-identifier hs-var">_co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; ThetaType -&gt; IOEnv (Env TcGblEnv TcLclEnv) HsWrapper
</span><a href="GHC.Tc.Utils.Instantiate.html#instCallConstraints"><span class="hs-identifier hs-var">instCallConstraints</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091652"><span class="hs-identifier hs-var">orig</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091651"><span class="hs-identifier hs-var">theta</span></a></span><span> </span><span class="hs-comment">-- Discard the coercion</span><span>
</span><span id="line-366"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcRn ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-367"></span><span>
</span><span id="line-368"></span><span>
</span><span id="line-369"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
         Instantiating Kinds
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-374"></span><span>
</span><span id="line-375"></span><span class="hs-comment">-- | Given ty::forall k1 k2. k, instantiate all the invisible forall-binders</span><span>
</span><span id="line-376"></span><span class="hs-comment">--   returning ty @kk1 @kk2 :: k[kk1/k1, kk2/k1]</span><span>
</span><span id="line-377"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstInvisibleTyBinders"><span class="hs-identifier hs-type">tcInstInvisibleTyBinders</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcKind"><span class="hs-identifier hs-type">TcKind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcKind"><span class="hs-identifier hs-type">TcKind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-378"></span><span id="tcInstInvisibleTyBinders"><span class="annot"><span class="annottext">tcInstInvisibleTyBinders :: Type -&gt; Type -&gt; TcM (Type, Type)
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstInvisibleTyBinders"><span class="hs-identifier hs-var hs-var">tcInstInvisibleTyBinders</span></a></span></span><span> </span><span id="local-6989586621681091648"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091648"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681091647"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091647"><span class="hs-identifier hs-var">kind</span></a></span></span><span>
</span><span id="line-379"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091646"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091646"><span class="hs-identifier hs-var">extra_args</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091645"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091645"><span class="hs-identifier hs-var">kind'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Type -&gt; TcM (ThetaType, Type)
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstInvisibleTyBindersN"><span class="hs-identifier hs-var">tcInstInvisibleTyBindersN</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681091644"><span class="hs-identifier hs-var">n_invis</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091647"><span class="hs-identifier hs-var">kind</span></a></span><span>
</span><span id="line-380"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Type, Type) -&gt; TcM (Type, Type)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; ThetaType -&gt; Type
</span><a href="GHC.Core.Type.html#mkAppTys"><span class="hs-identifier hs-var">mkAppTys</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091648"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091646"><span class="hs-identifier hs-var">extra_args</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091645"><span class="hs-identifier hs-var">kind'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-381"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-382"></span><span>    </span><span id="local-6989586621681091644"><span class="annot"><span class="annottext">n_invis :: Int
</span><a href="#local-6989586621681091644"><span class="hs-identifier hs-var hs-var">n_invis</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Int
</span><a href="GHC.Core.Type.html#invisibleTyBndrCount"><span class="hs-identifier hs-var">invisibleTyBndrCount</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091647"><span class="hs-identifier hs-var">kind</span></a></span><span>
</span><span id="line-383"></span><span>
</span><span id="line-384"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstInvisibleTyBindersN"><span class="hs-identifier hs-type">tcInstInvisibleTyBindersN</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcKind"><span class="hs-identifier hs-type">TcKind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcKind"><span class="hs-identifier hs-type">TcKind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-385"></span><span id="tcInstInvisibleTyBindersN"><span class="annot"><span class="annottext">tcInstInvisibleTyBindersN :: Int -&gt; Type -&gt; TcM (ThetaType, Type)
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstInvisibleTyBindersN"><span class="hs-identifier hs-var hs-var">tcInstInvisibleTyBindersN</span></a></span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span id="local-6989586621681091641"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091641"><span class="hs-identifier hs-var">kind</span></a></span></span><span>
</span><span id="line-386"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(ThetaType, Type) -&gt; TcM (ThetaType, Type)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091641"><span class="hs-identifier hs-var">kind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-387"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstInvisibleTyBindersN"><span class="hs-identifier hs-var">tcInstInvisibleTyBindersN</span></a></span><span> </span><span id="local-6989586621681091640"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681091640"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681091639"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091639"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-388"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; TCvSubst -&gt; Type -&gt; TcM (ThetaType, Type)
forall {t}.
(Ord t, Num t) =&gt;
t -&gt; TCvSubst -&gt; Type -&gt; TcM (ThetaType, Type)
</span><a href="#local-6989586621681091638"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621681091640"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091637"><span class="hs-identifier hs-var">empty_subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091639"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-389"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-390"></span><span>    </span><span id="local-6989586621681091637"><span class="annot"><span class="annottext">empty_subst :: TCvSubst
</span><a href="#local-6989586621681091637"><span class="hs-identifier hs-var hs-var">empty_subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkEmptyTCvSubst"><span class="hs-identifier hs-var">mkEmptyTCvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091639"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-391"></span><span>
</span><span id="line-392"></span><span>    </span><span id="local-6989586621681091638"><span class="annot"><span class="annottext">go :: t -&gt; TCvSubst -&gt; Type -&gt; TcM (ThetaType, Type)
</span><a href="#local-6989586621681091638"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621681091624"><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621681091624"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621681091623"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091623"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621681091622"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091622"><span class="hs-identifier hs-var">kind</span></a></span></span><span>
</span><span id="line-393"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621681091624"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">t -&gt; t -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;</span></span><span> </span><span class="annot"><span class="annottext">t
</span><span class="hs-number">0</span></span><span>
</span><span id="line-394"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091620"><span class="annot"><span class="annottext">TyBinder
</span><a href="#local-6989586621681091620"><span class="hs-identifier hs-var">bndr</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091619"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091619"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (TyBinder, Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitPiTy_maybe"><span class="hs-identifier hs-var">tcSplitPiTy_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091622"><span class="hs-identifier hs-var">kind</span></a></span><span>
</span><span id="line-395"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyBinder -&gt; Bool
</span><a href="GHC.Core.TyCo.Rep.html#isInvisibleBinder"><span class="hs-identifier hs-var">isInvisibleBinder</span></a></span><span> </span><span class="annot"><span class="annottext">TyBinder
</span><a href="#local-6989586621681091620"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-396"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091616"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091616"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091615"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091615"><span class="hs-identifier hs-var">arg</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; TyBinder -&gt; TcM (TCvSubst, Type)
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstInvisibleTyBinder"><span class="hs-identifier hs-var">tcInstInvisibleTyBinder</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091623"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">TyBinder
</span><a href="#local-6989586621681091620"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-397"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091614"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091614"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091613"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091613"><span class="hs-identifier hs-var">inner_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">t -&gt; TCvSubst -&gt; Type -&gt; TcM (ThetaType, Type)
</span><a href="#local-6989586621681091638"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621681091624"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">t -&gt; t -&gt; t
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">t
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091616"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091619"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-398"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(ThetaType, Type) -&gt; TcM (ThetaType, Type)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091615"><span class="hs-identifier hs-var">arg</span></a></span><span class="annot"><span class="annottext">Type -&gt; ThetaType -&gt; ThetaType
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091614"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091613"><span class="hs-identifier hs-var">inner_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-399"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-400"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(ThetaType, Type) -&gt; TcM (ThetaType, Type)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091623"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091622"><span class="hs-identifier hs-var">kind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-401"></span><span>
</span><span id="line-402"></span><span class="hs-comment">-- | Used only in *types*</span><span>
</span><span id="line-403"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstInvisibleTyBinder"><span class="hs-identifier hs-type">tcInstInvisibleTyBinder</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#TyBinder"><span class="hs-identifier hs-type">TyBinder</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-404"></span><span id="tcInstInvisibleTyBinder"><span class="annot"><span class="annottext">tcInstInvisibleTyBinder :: TCvSubst -&gt; TyBinder -&gt; TcM (TCvSubst, Type)
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstInvisibleTyBinder"><span class="hs-identifier hs-var hs-var">tcInstInvisibleTyBinder</span></a></span></span><span> </span><span id="local-6989586621681091612"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091612"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Named"><span class="hs-identifier hs-type">Named</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-type">Bndr</span></a></span><span> </span><span id="local-6989586621681091609"><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091609"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="annot"><span class="annottext">ArgFlag
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-405"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091608"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091608"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091607"><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091607"><span class="hs-identifier hs-var">tv'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TCvSubst
-&gt; DFunId -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, DFunId)
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarX"><span class="hs-identifier hs-var">newMetaTyVarX</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091612"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091609"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-406"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TCvSubst, Type) -&gt; TcM (TCvSubst, Type)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091608"><span class="hs-identifier hs-var">subst'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">DFunId -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091607"><span class="hs-identifier hs-var">tv'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-407"></span><span>
</span><span id="line-408"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstInvisibleTyBinder"><span class="hs-identifier hs-var">tcInstInvisibleTyBinder</span></a></span><span> </span><span id="local-6989586621681091606"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091606"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Anon"><span class="hs-identifier hs-type">Anon</span></a></span><span> </span><span id="local-6989586621681091604"><span class="annot"><span class="annottext">AnonArgFlag
</span><a href="#local-6989586621681091604"><span class="hs-identifier hs-var">af</span></a></span></span><span> </span><span id="local-6989586621681091603"><span class="annot"><span class="annottext">Scaled Type
</span><a href="#local-6989586621681091603"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-409"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091602"><span class="annot"><span class="annottext">Coercion -&gt; TcM Type
</span><a href="#local-6989586621681091602"><span class="hs-identifier hs-var">mk</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091601"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091601"><span class="hs-identifier hs-var">k1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091600"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091600"><span class="hs-identifier hs-var">k2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe (Coercion -&gt; TcM Type, Type, Type)
</span><a href="GHC.Tc.Utils.Instantiate.html#get_eq_tys_maybe"><span class="hs-identifier hs-var">get_eq_tys_maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091606"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Scaled Type -&gt; Type
forall a. Scaled a -&gt; a
</span><a href="GHC.Core.TyCo.Rep.html#scaledThing"><span class="hs-identifier hs-var">scaledThing</span></a></span><span> </span><span class="annot"><span class="annottext">Scaled Type
</span><a href="#local-6989586621681091603"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-410"></span><span>    </span><span class="hs-comment">-- Equality is the *only* constraint currently handled in types.</span><span>
</span><span id="line-411"></span><span>    </span><span class="hs-comment">-- See Note [Constraints in kinds] in GHC.Core.TyCo.Rep</span><span>
</span><span id="line-412"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">af</span><span> </span><span class="hs-operator">==</span><span> </span><span class="hs-identifier">InvisArg</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-413"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681091596"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681091596"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (HsType GhcRn) -&gt; Type -&gt; Type -&gt; TcM Coercion
</span><a href="GHC.Tc.Utils.Unify.html#unifyKind"><span class="hs-identifier hs-var">unifyKind</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (HsType GhcRn)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091601"><span class="hs-identifier hs-var">k1</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091600"><span class="hs-identifier hs-var">k2</span></a></span><span>
</span><span id="line-414"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681091595"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091595"><span class="hs-identifier hs-var">arg'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; TcM Type
</span><a href="#local-6989586621681091602"><span class="hs-identifier hs-var">mk</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681091596"><span class="hs-identifier hs-var">co</span></a></span><span>
</span><span id="line-415"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TCvSubst, Type) -&gt; TcM (TCvSubst, Type)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091606"><span class="hs-identifier hs-var">subst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091595"><span class="hs-identifier hs-var">arg'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-416"></span><span>
</span><span id="line-417"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-comment">-- This should never happen</span><span>
</span><span id="line-418"></span><span>               </span><span class="hs-comment">-- See GHC.Core.TyCo.Rep Note [Constraints in kinds]</span><span>
</span><span id="line-419"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM (TCvSubst, Type)
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcInvisibleTyBinder&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Scaled Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Scaled Type
</span><a href="#local-6989586621681091603"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-420"></span><span>
</span><span id="line-421"></span><span class="hs-comment">-------------------------------</span><span>
</span><span id="line-422"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#get_eq_tys_maybe"><span class="hs-identifier hs-type">get_eq_tys_maybe</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-423"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Coercion"><span class="hs-identifier hs-type">Coercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-424"></span><span>                             </span><span class="hs-comment">-- given a coercion proving t1 ~# t2, produce the</span><span>
</span><span id="line-425"></span><span>                             </span><span class="hs-comment">-- right instantiation for the TyBinder at hand</span><span>
</span><span id="line-426"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>  </span><span class="hs-comment">-- t1</span><span>
</span><span id="line-427"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>  </span><span class="hs-comment">-- t2</span><span>
</span><span id="line-428"></span><span>                          </span><span class="hs-special">)</span><span>
</span><span id="line-429"></span><span class="hs-comment">-- See Note [Constraints in kinds] in GHC.Core.TyCo.Rep</span><span>
</span><span id="line-430"></span><span id="get_eq_tys_maybe"><span class="annot"><span class="annottext">get_eq_tys_maybe :: Type -&gt; Maybe (Coercion -&gt; TcM Type, Type, Type)
</span><a href="GHC.Tc.Utils.Instantiate.html#get_eq_tys_maybe"><span class="hs-identifier hs-var hs-var">get_eq_tys_maybe</span></a></span></span><span> </span><span id="local-6989586621681091594"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091594"><span class="hs-identifier hs-var">ty</span></a></span></span><span>
</span><span id="line-431"></span><span>  </span><span class="hs-comment">-- Lifted heterogeneous equality (~~)</span><span>
</span><span id="line-432"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091593"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681091593"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091592"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091592"><span class="hs-identifier hs-var">k1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091591"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091591"><span class="hs-identifier hs-var">k2</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (TyCon, ThetaType)
Type -&gt; Maybe (TyCon, ThetaType)
</span><a href="GHC.Core.Type.html#splitTyConApp_maybe"><span class="hs-identifier hs-var">splitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091594"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-433"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681091593"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#heqTyConKey"><span class="hs-identifier hs-var">heqTyConKey</span></a></span><span>
</span><span id="line-434"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; TcM Type, Type, Type)
-&gt; Maybe (Coercion -&gt; TcM Type, Type, Type)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681091590"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681091590"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Type -&gt; Type -&gt; TcM Type
</span><a href="GHC.Tc.Utils.Instantiate.html#mkHEqBoxTy"><span class="hs-identifier hs-var">mkHEqBoxTy</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681091590"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091592"><span class="hs-identifier hs-var">k1</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091591"><span class="hs-identifier hs-var">k2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091592"><span class="hs-identifier hs-var">k1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091591"><span class="hs-identifier hs-var">k2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-435"></span><span>
</span><span id="line-436"></span><span>  </span><span class="hs-comment">-- Lifted homogeneous equality (~)</span><span>
</span><span id="line-437"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091588"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681091588"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091587"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091587"><span class="hs-identifier hs-var">k1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091586"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091586"><span class="hs-identifier hs-var">k2</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe (TyCon, ThetaType)
Type -&gt; Maybe (TyCon, ThetaType)
</span><a href="GHC.Core.Type.html#splitTyConApp_maybe"><span class="hs-identifier hs-var">splitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091594"><span class="hs-identifier hs-var">ty</span></a></span><span>
</span><span id="line-438"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681091588"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Unique -&gt; Bool
forall a. Uniquable a =&gt; a -&gt; Unique -&gt; Bool
</span><a href="GHC.Types.Unique.html#hasKey"><span class="hs-operator hs-var">`hasKey`</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#eqTyConKey"><span class="hs-identifier hs-var">eqTyConKey</span></a></span><span>
</span><span id="line-439"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Coercion -&gt; TcM Type, Type, Type)
-&gt; Maybe (Coercion -&gt; TcM Type, Type, Type)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621681091584"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681091584"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Type -&gt; Type -&gt; TcM Type
</span><a href="GHC.Tc.Utils.Instantiate.html#mkEqBoxTy"><span class="hs-identifier hs-var">mkEqBoxTy</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681091584"><span class="hs-identifier hs-var">co</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091587"><span class="hs-identifier hs-var">k1</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091586"><span class="hs-identifier hs-var">k2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091587"><span class="hs-identifier hs-var">k1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091586"><span class="hs-identifier hs-var">k2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-440"></span><span>
</span><span id="line-441"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-442"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (Coercion -&gt; TcM Type, Type, Type)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-443"></span><span>
</span><span id="line-444"></span><span class="hs-comment">-- | This takes @a ~# b@ and returns @a ~~ b@.</span><span>
</span><span id="line-445"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#mkHEqBoxTy"><span class="hs-identifier hs-type">mkHEqBoxTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcCoercion"><span class="hs-identifier hs-type">TcCoercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-446"></span><span class="hs-comment">-- monadic just for convenience with mkEqBoxTy</span><span>
</span><span id="line-447"></span><span id="mkHEqBoxTy"><span class="annot"><span class="annottext">mkHEqBoxTy :: Coercion -&gt; Type -&gt; Type -&gt; TcM Type
</span><a href="GHC.Tc.Utils.Instantiate.html#mkHEqBoxTy"><span class="hs-identifier hs-var hs-var">mkHEqBoxTy</span></a></span></span><span> </span><span id="local-6989586621681091581"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681091581"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621681091580"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091580"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681091579"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091579"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-448"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; TcM Type
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; TcM Type) -&gt; Type -&gt; TcM Type
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-449"></span><span>    </span><span class="annot"><span class="annottext">TyCon -&gt; ThetaType -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyConApp"><span class="hs-identifier hs-var">mkTyConApp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; TyCon
</span><a href="GHC.Core.DataCon.html#promoteDataCon"><span class="hs-identifier hs-var">promoteDataCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="GHC.Builtin.Types.html#heqDataCon"><span class="hs-identifier hs-var">heqDataCon</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091576"><span class="hs-identifier hs-var">k1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091575"><span class="hs-identifier hs-var">k2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091580"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091579"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Type
</span><a href="GHC.Core.Type.html#mkCoercionTy"><span class="hs-identifier hs-var">mkCoercionTy</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681091581"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-450"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681091576"><span class="annot"><span class="annottext">k1 :: Type
</span><a href="#local-6989586621681091576"><span class="hs-identifier hs-var hs-var">k1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Type
Type -&gt; Type
</span><a href="GHC.Core.Type.html#tcTypeKind"><span class="hs-identifier hs-var">tcTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091580"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-451"></span><span>        </span><span id="local-6989586621681091575"><span class="annot"><span class="annottext">k2 :: Type
</span><a href="#local-6989586621681091575"><span class="hs-identifier hs-var hs-var">k2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Type
Type -&gt; Type
</span><a href="GHC.Core.Type.html#tcTypeKind"><span class="hs-identifier hs-var">tcTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091579"><span class="hs-identifier hs-var">ty2</span></a></span><span>
</span><span id="line-452"></span><span>
</span><span id="line-453"></span><span class="hs-comment">-- | This takes @a ~# b@ and returns @a ~ b@.</span><span>
</span><span id="line-454"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#mkEqBoxTy"><span class="hs-identifier hs-type">mkEqBoxTy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcCoercion"><span class="hs-identifier hs-type">TcCoercion</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-455"></span><span id="mkEqBoxTy"><span class="annot"><span class="annottext">mkEqBoxTy :: Coercion -&gt; Type -&gt; Type -&gt; TcM Type
</span><a href="GHC.Tc.Utils.Instantiate.html#mkEqBoxTy"><span class="hs-identifier hs-var hs-var">mkEqBoxTy</span></a></span></span><span> </span><span id="local-6989586621681091571"><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681091571"><span class="hs-identifier hs-var">co</span></a></span></span><span> </span><span id="local-6989586621681091570"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091570"><span class="hs-identifier hs-var">ty1</span></a></span></span><span> </span><span id="local-6989586621681091569"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091569"><span class="hs-identifier hs-var">ty2</span></a></span></span><span>
</span><span id="line-456"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; TcM Type
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; TcM Type) -&gt; Type -&gt; TcM Type
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-457"></span><span>    </span><span class="annot"><span class="annottext">TyCon -&gt; ThetaType -&gt; Type
</span><a href="GHC.Core.TyCo.Rep.html#mkTyConApp"><span class="hs-identifier hs-var">mkTyConApp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; TyCon
</span><a href="GHC.Core.DataCon.html#promoteDataCon"><span class="hs-identifier hs-var">promoteDataCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="GHC.Builtin.Types.html#eqDataCon"><span class="hs-identifier hs-var">eqDataCon</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091568"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091570"><span class="hs-identifier hs-var">ty1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091569"><span class="hs-identifier hs-var">ty2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Coercion -&gt; Type
</span><a href="GHC.Core.Type.html#mkCoercionTy"><span class="hs-identifier hs-var">mkCoercionTy</span></a></span><span> </span><span class="annot"><span class="annottext">Coercion
</span><a href="#local-6989586621681091571"><span class="hs-identifier hs-var">co</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-458"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621681091568"><span class="annot"><span class="annottext">k :: Type
</span><a href="#local-6989586621681091568"><span class="hs-identifier hs-var hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Type
Type -&gt; Type
</span><a href="GHC.Core.Type.html#tcTypeKind"><span class="hs-identifier hs-var">tcTypeKind</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091570"><span class="hs-identifier hs-var">ty1</span></a></span><span>
</span><span id="line-459"></span><span>
</span><span id="line-460"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
        SkolemTvs (immutable)
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-465"></span><span>
</span><span id="line-466"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstType"><span class="hs-identifier hs-type">tcInstType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-467"></span><span>                   </span><span class="hs-comment">-- ^ How to instantiate the type variables</span><span>
</span><span id="line-468"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span>                                           </span><span class="hs-comment">-- ^ Type to instantiate</span><span>
</span><span id="line-469"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcThetaType"><span class="hs-identifier hs-type">TcThetaType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- ^ Result</span><span>
</span><span id="line-470"></span><span>                </span><span class="hs-comment">-- (type vars, preds (incl equalities), rho)</span><span>
</span><span id="line-471"></span><span id="tcInstType"><span class="annot"><span class="annottext">tcInstType :: ([DFunId] -&gt; TcM (TCvSubst, [DFunId]))
-&gt; DFunId -&gt; TcM ([(Name, DFunId)], ThetaType, Type)
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstType"><span class="hs-identifier hs-var hs-var">tcInstType</span></a></span></span><span> </span><span id="local-6989586621681091564"><span class="annot"><span class="annottext">[DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="#local-6989586621681091564"><span class="hs-identifier hs-var">inst_tyvars</span></a></span></span><span> </span><span id="local-6989586621681091563"><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091563"><span class="hs-identifier hs-var">id</span></a></span></span><span>
</span><span id="line-472"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[DFunId] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091562"><span class="hs-identifier hs-var">tyvars</span></a></span><span>   </span><span class="hs-comment">-- There may be overloading despite no type variables;</span><span>
</span><span id="line-473"></span><span>                  </span><span class="hs-comment">--      (?x :: Int) =&gt; Int -&gt; Int</span><span>
</span><span id="line-474"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([(Name, DFunId)], ThetaType, Type)
-&gt; TcM ([(Name, DFunId)], ThetaType, Type)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091561"><span class="hs-identifier hs-var">theta</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091560"><span class="hs-identifier hs-var">tau</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-475"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-476"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091559"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091559"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091558"><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091558"><span class="hs-identifier hs-var">tyvars'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="#local-6989586621681091564"><span class="hs-identifier hs-var">inst_tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091562"><span class="hs-identifier hs-var">tyvars</span></a></span><span>
</span><span id="line-477"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681091557"><span class="annot"><span class="annottext">tv_prs :: [(Name, DFunId)]
</span><a href="#local-6989586621681091557"><span class="hs-identifier hs-var hs-var">tv_prs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(DFunId -&gt; Name) -&gt; [DFunId] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId -&gt; Name
</span><a href="GHC.Types.Var.html#tyVarName"><span class="hs-identifier hs-var">tyVarName</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091562"><span class="hs-identifier hs-var">tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">[Name] -&gt; [DFunId] -&gt; [(Name, DFunId)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091558"><span class="hs-identifier hs-var">tyvars'</span></a></span><span>
</span><span id="line-478"></span><span>             </span><span id="local-6989586621681091556"><span class="annot"><span class="annottext">subst' :: TCvSubst
</span><a href="#local-6989586621681091556"><span class="hs-identifier hs-var hs-var">subst'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; VarSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTCvInScopeSet"><span class="hs-identifier hs-var">extendTCvInScopeSet</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091559"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091554"><span class="hs-identifier hs-var">rho</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-479"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([(Name, DFunId)], ThetaType, Type)
-&gt; TcM ([(Name, DFunId)], ThetaType, Type)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Name, DFunId)]
</span><a href="#local-6989586621681091557"><span class="hs-identifier hs-var">tv_prs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; ThetaType -&gt; ThetaType
TCvSubst -&gt; ThetaType -&gt; ThetaType
</span><a href="GHC.Core.TyCo.Subst.html#substTheta"><span class="hs-identifier hs-var">substTheta</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091556"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091561"><span class="hs-identifier hs-var">theta</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091556"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091560"><span class="hs-identifier hs-var">tau</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-480"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-481"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681091562"><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091562"><span class="hs-identifier hs-var">tyvars</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091554"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091554"><span class="hs-identifier hs-var">rho</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([DFunId], Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitForAllTys"><span class="hs-identifier hs-var">tcSplitForAllTys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DFunId -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091563"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-482"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681091561"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091561"><span class="hs-identifier hs-var">theta</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091560"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091560"><span class="hs-identifier hs-var">tau</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; (ThetaType, Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitPhiTy"><span class="hs-identifier hs-var">tcSplitPhiTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091554"><span class="hs-identifier hs-var">rho</span></a></span><span>
</span><span id="line-483"></span><span>
</span><span id="line-484"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstTypeBndrs"><span class="hs-identifier hs-type">tcInstTypeBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#InvisTVBinder"><span class="hs-identifier hs-type">InvisTVBinder</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcThetaType"><span class="hs-identifier hs-type">TcThetaType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-485"></span><span>                     </span><span class="hs-comment">-- (type vars, preds (incl equalities), rho)</span><span>
</span><span id="line-486"></span><span class="hs-comment">-- Instantiate the binders of a type signature with TyVarTvs</span><span>
</span><span id="line-487"></span><span id="tcInstTypeBndrs"><span class="annot"><span class="annottext">tcInstTypeBndrs :: DFunId -&gt; TcM ([(Name, InvisTVBinder)], ThetaType, Type)
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstTypeBndrs"><span class="hs-identifier hs-var hs-var">tcInstTypeBndrs</span></a></span></span><span> </span><span id="local-6989586621681091552"><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091552"><span class="hs-identifier hs-var">id</span></a></span></span><span>
</span><span id="line-488"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[InvisTVBinder] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[InvisTVBinder]
</span><a href="#local-6989586621681091551"><span class="hs-identifier hs-var">tyvars</span></a></span><span>   </span><span class="hs-comment">-- There may be overloading despite no type variables;</span><span>
</span><span id="line-489"></span><span>                  </span><span class="hs-comment">--      (?x :: Int) =&gt; Int -&gt; Int</span><span>
</span><span id="line-490"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([(Name, InvisTVBinder)], ThetaType, Type)
-&gt; TcM ([(Name, InvisTVBinder)], ThetaType, Type)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091550"><span class="hs-identifier hs-var">theta</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091549"><span class="hs-identifier hs-var">tau</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-491"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-492"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091548"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091548"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091547"><span class="annot"><span class="annottext">[InvisTVBinder]
</span><a href="#local-6989586621681091547"><span class="hs-identifier hs-var">tyvars'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TCvSubst
 -&gt; InvisTVBinder
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, InvisTVBinder))
-&gt; TCvSubst
-&gt; [InvisTVBinder]
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, [InvisTVBinder])
forall (m :: * -&gt; *) acc x y.
Monad m =&gt;
(acc -&gt; x -&gt; m (acc, y)) -&gt; acc -&gt; [x] -&gt; m (acc, [y])
</span><a href="GHC.Utils.Monad.html#mapAccumLM"><span class="hs-identifier hs-var">mapAccumLM</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
-&gt; InvisTVBinder
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, InvisTVBinder)
</span><a href="#local-6989586621681091546"><span class="hs-identifier hs-var">inst_invis_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#emptyTCvSubst"><span class="hs-identifier hs-var">emptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">[InvisTVBinder]
</span><a href="#local-6989586621681091551"><span class="hs-identifier hs-var">tyvars</span></a></span><span>
</span><span id="line-493"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681091545"><span class="annot"><span class="annottext">tv_prs :: [(Name, InvisTVBinder)]
</span><a href="#local-6989586621681091545"><span class="hs-identifier hs-var hs-var">tv_prs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(InvisTVBinder -&gt; Name) -&gt; [InvisTVBinder] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DFunId -&gt; Name
</span><a href="GHC.Types.Var.html#tyVarName"><span class="hs-identifier hs-var">tyVarName</span></a></span><span> </span><span class="annot"><span class="annottext">(DFunId -&gt; Name)
-&gt; (InvisTVBinder -&gt; DFunId) -&gt; InvisTVBinder -&gt; Name
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">InvisTVBinder -&gt; DFunId
forall tv argf. VarBndr tv argf -&gt; tv
</span><a href="GHC.Types.Var.html#binderVar"><span class="hs-identifier hs-var">binderVar</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[InvisTVBinder]
</span><a href="#local-6989586621681091551"><span class="hs-identifier hs-var">tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">[Name] -&gt; [InvisTVBinder] -&gt; [(Name, InvisTVBinder)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[InvisTVBinder]
</span><a href="#local-6989586621681091547"><span class="hs-identifier hs-var">tyvars'</span></a></span><span>
</span><span id="line-494"></span><span>             </span><span id="local-6989586621681091542"><span class="annot"><span class="annottext">subst' :: TCvSubst
</span><a href="#local-6989586621681091542"><span class="hs-identifier hs-var hs-var">subst'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; VarSet -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTCvInScopeSet"><span class="hs-identifier hs-var">extendTCvInScopeSet</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091548"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091541"><span class="hs-identifier hs-var">rho</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-495"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([(Name, InvisTVBinder)], ThetaType, Type)
-&gt; TcM ([(Name, InvisTVBinder)], ThetaType, Type)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(Name, InvisTVBinder)]
</span><a href="#local-6989586621681091545"><span class="hs-identifier hs-var">tv_prs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; ThetaType -&gt; ThetaType
TCvSubst -&gt; ThetaType -&gt; ThetaType
</span><a href="GHC.Core.TyCo.Subst.html#substTheta"><span class="hs-identifier hs-var">substTheta</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091542"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091550"><span class="hs-identifier hs-var">theta</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091542"><span class="hs-identifier hs-var">subst'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091549"><span class="hs-identifier hs-var">tau</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-496"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-497"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681091551"><span class="annot"><span class="annottext">[InvisTVBinder]
</span><a href="#local-6989586621681091551"><span class="hs-identifier hs-var">tyvars</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091541"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091541"><span class="hs-identifier hs-var">rho</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([InvisTVBinder], Type)
</span><a href="GHC.Core.Type.html#splitForAllTysInvis"><span class="hs-identifier hs-var">splitForAllTysInvis</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DFunId -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091552"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-498"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621681091550"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091550"><span class="hs-identifier hs-var">theta</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091549"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091549"><span class="hs-identifier hs-var">tau</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; (ThetaType, Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitPhiTy"><span class="hs-identifier hs-var">tcSplitPhiTy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091541"><span class="hs-identifier hs-var">rho</span></a></span><span>
</span><span id="line-499"></span><span>
</span><span id="line-500"></span><span>    </span><span class="annot"><a href="#local-6989586621681091546"><span class="hs-identifier hs-type">inst_invis_bndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#InvisTVBinder"><span class="hs-identifier hs-type">InvisTVBinder</span></a></span><span>
</span><span id="line-501"></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#InvisTVBinder"><span class="hs-identifier hs-type">InvisTVBinder</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-502"></span><span>    </span><span id="local-6989586621681091546"><span class="annot"><span class="annottext">inst_invis_bndr :: TCvSubst
-&gt; InvisTVBinder
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, InvisTVBinder)
</span><a href="#local-6989586621681091546"><span class="hs-identifier hs-var hs-var">inst_invis_bndr</span></a></span></span><span> </span><span id="local-6989586621681091539"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091539"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-type">Bndr</span></a></span><span> </span><span id="local-6989586621681091538"><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091538"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span id="local-6989586621681091537"><span class="annot"><span class="annottext">Specificity
</span><a href="#local-6989586621681091537"><span class="hs-identifier hs-var">spec</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-503"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091536"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091536"><span class="hs-identifier hs-var">subst'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091535"><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091535"><span class="hs-identifier hs-var">tv'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TCvSubst
-&gt; DFunId -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, DFunId)
</span><a href="GHC.Tc.Utils.TcMType.html#newMetaTyVarTyVarX"><span class="hs-identifier hs-var">newMetaTyVarTyVarX</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091539"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091538"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-504"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TCvSubst, InvisTVBinder)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, InvisTVBinder)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091536"><span class="hs-identifier hs-var">subst'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">DFunId -&gt; Specificity -&gt; InvisTVBinder
forall var argf. var -&gt; argf -&gt; VarBndr var argf
</span><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-var">Bndr</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091535"><span class="hs-identifier hs-var">tv'</span></a></span><span> </span><span class="annot"><span class="annottext">Specificity
</span><a href="#local-6989586621681091537"><span class="hs-identifier hs-var">spec</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-505"></span><span>
</span><span id="line-506"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcSkolDFunType"><span class="hs-identifier hs-type">tcSkolDFunType</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#DFunId"><span class="hs-identifier hs-type">DFunId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcThetaType"><span class="hs-identifier hs-type">TcThetaType</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-507"></span><span class="hs-comment">-- Instantiate a type signature with skolem constants.</span><span>
</span><span id="line-508"></span><span class="hs-comment">-- We could give them fresh names, but no need to do so</span><span>
</span><span id="line-509"></span><span id="tcSkolDFunType"><span class="annot"><span class="annottext">tcSkolDFunType :: DFunId -&gt; TcM ([DFunId], ThetaType, Type)
</span><a href="GHC.Tc.Utils.Instantiate.html#tcSkolDFunType"><span class="hs-identifier hs-var hs-var">tcSkolDFunType</span></a></span></span><span> </span><span id="local-6989586621681091533"><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091533"><span class="hs-identifier hs-var">dfun</span></a></span></span><span>
</span><span id="line-510"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091532"><span class="annot"><span class="annottext">[(Name, DFunId)]
</span><a href="#local-6989586621681091532"><span class="hs-identifier hs-var">tv_prs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091531"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091531"><span class="hs-identifier hs-var">theta</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091530"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091530"><span class="hs-identifier hs-var">tau</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">([DFunId] -&gt; TcM (TCvSubst, [DFunId]))
-&gt; DFunId -&gt; TcM ([(Name, DFunId)], ThetaType, Type)
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstType"><span class="hs-identifier hs-var">tcInstType</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstSuperSkolTyVars"><span class="hs-identifier hs-var">tcInstSuperSkolTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091533"><span class="hs-identifier hs-var">dfun</span></a></span><span>
</span><span id="line-511"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([DFunId], ThetaType, Type) -&gt; TcM ([DFunId], ThetaType, Type)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((Name, DFunId) -&gt; DFunId) -&gt; [(Name, DFunId)] -&gt; [DFunId]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Name, DFunId) -&gt; DFunId
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, DFunId)]
</span><a href="#local-6989586621681091532"><span class="hs-identifier hs-var">tv_prs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091531"><span class="hs-identifier hs-var">theta</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091530"><span class="hs-identifier hs-var">tau</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-512"></span><span>
</span><span id="line-513"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcSuperSkolTyVars"><span class="hs-identifier hs-type">tcSuperSkolTyVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-514"></span><span class="hs-comment">-- Make skolem constants, but do *not* give them new names, as above</span><span>
</span><span id="line-515"></span><span class="hs-comment">-- Moreover, make them &quot;super skolems&quot;; see comments with superSkolemTv</span><span>
</span><span id="line-516"></span><span class="hs-comment">-- see Note [Kind substitution when instantiating]</span><span>
</span><span id="line-517"></span><span class="hs-comment">-- Precondition: tyvars should be ordered by scoping</span><span>
</span><span id="line-518"></span><span id="tcSuperSkolTyVars"><span class="annot"><span class="annottext">tcSuperSkolTyVars :: [DFunId] -&gt; (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#tcSuperSkolTyVars"><span class="hs-identifier hs-var hs-var">tcSuperSkolTyVars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TCvSubst -&gt; DFunId -&gt; (TCvSubst, DFunId))
-&gt; TCvSubst -&gt; [DFunId] -&gt; (TCvSubst, [DFunId])
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; DFunId -&gt; (TCvSubst, DFunId)
</span><a href="GHC.Tc.Utils.Instantiate.html#tcSuperSkolTyVar"><span class="hs-identifier hs-var">tcSuperSkolTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#emptyTCvSubst"><span class="hs-identifier hs-var">emptyTCvSubst</span></a></span><span>
</span><span id="line-519"></span><span>
</span><span id="line-520"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcSuperSkolTyVar"><span class="hs-identifier hs-type">tcSuperSkolTyVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-521"></span><span id="tcSuperSkolTyVar"><span class="annot"><span class="annottext">tcSuperSkolTyVar :: TCvSubst -&gt; DFunId -&gt; (TCvSubst, DFunId)
</span><a href="GHC.Tc.Utils.Instantiate.html#tcSuperSkolTyVar"><span class="hs-identifier hs-var hs-var">tcSuperSkolTyVar</span></a></span></span><span> </span><span id="local-6989586621681091527"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091527"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621681091526"><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091526"><span class="hs-identifier hs-var">tv</span></a></span></span><span>
</span><span id="line-522"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst -&gt; DFunId -&gt; DFunId -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTvSubstWithClone"><span class="hs-identifier hs-var">extendTvSubstWithClone</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091527"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091526"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091524"><span class="hs-identifier hs-var">new_tv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091524"><span class="hs-identifier hs-var">new_tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-523"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-524"></span><span>    </span><span id="local-6989586621681091523"><span class="annot"><span class="annottext">kind :: Type
</span><a href="#local-6989586621681091523"><span class="hs-identifier hs-var hs-var">kind</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyUnchecked"><span class="hs-identifier hs-var">substTyUnchecked</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091527"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DFunId -&gt; Type
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091526"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-525"></span><span>    </span><span id="local-6989586621681091524"><span class="annot"><span class="annottext">new_tv :: DFunId
</span><a href="#local-6989586621681091524"><span class="hs-identifier hs-var hs-var">new_tv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Type -&gt; TcTyVarDetails -&gt; DFunId
</span><a href="GHC.Types.Var.html#mkTcTyVar"><span class="hs-identifier hs-var">mkTcTyVar</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DFunId -&gt; Name
</span><a href="GHC.Types.Var.html#tyVarName"><span class="hs-identifier hs-var">tyVarName</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091526"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091523"><span class="hs-identifier hs-var">kind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcType.html#superSkolemTv"><span class="hs-identifier hs-var">superSkolemTv</span></a></span><span>
</span><span id="line-526"></span><span>
</span><span id="line-527"></span><span class="hs-comment">-- | Given a list of @['TyVar']@, skolemize the type variables,</span><span>
</span><span id="line-528"></span><span class="hs-comment">-- returning a substitution mapping the original tyvars to the</span><span>
</span><span id="line-529"></span><span class="hs-comment">-- skolems, and the list of newly bound skolems.</span><span>
</span><span id="line-530"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstSkolTyVars"><span class="hs-identifier hs-type">tcInstSkolTyVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-531"></span><span class="hs-comment">-- See Note [Skolemising type variables]</span><span>
</span><span id="line-532"></span><span id="tcInstSkolTyVars"><span class="annot"><span class="annottext">tcInstSkolTyVars :: [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstSkolTyVars"><span class="hs-identifier hs-var hs-var">tcInstSkolTyVars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstSkolTyVarsX"><span class="hs-identifier hs-var">tcInstSkolTyVarsX</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#emptyTCvSubst"><span class="hs-identifier hs-var">emptyTCvSubst</span></a></span><span>
</span><span id="line-533"></span><span>
</span><span id="line-534"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstSkolTyVarsX"><span class="hs-identifier hs-type">tcInstSkolTyVarsX</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-535"></span><span class="hs-comment">-- See Note [Skolemising type variables]</span><span>
</span><span id="line-536"></span><span id="tcInstSkolTyVarsX"><span class="annot"><span class="annottext">tcInstSkolTyVarsX :: TCvSubst -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstSkolTyVarsX"><span class="hs-identifier hs-var hs-var">tcInstSkolTyVarsX</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TCvSubst -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstSkolTyVarsPushLevel"><span class="hs-identifier hs-var">tcInstSkolTyVarsPushLevel</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-537"></span><span>
</span><span id="line-538"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstSuperSkolTyVars"><span class="hs-identifier hs-type">tcInstSuperSkolTyVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-539"></span><span class="hs-comment">-- See Note [Skolemising type variables]</span><span>
</span><span id="line-540"></span><span id="tcInstSuperSkolTyVars"><span class="annot"><span class="annottext">tcInstSuperSkolTyVars :: [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstSuperSkolTyVars"><span class="hs-identifier hs-var hs-var">tcInstSuperSkolTyVars</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstSuperSkolTyVarsX"><span class="hs-identifier hs-var">tcInstSuperSkolTyVarsX</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#emptyTCvSubst"><span class="hs-identifier hs-var">emptyTCvSubst</span></a></span><span>
</span><span id="line-541"></span><span>
</span><span id="line-542"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstSuperSkolTyVarsX"><span class="hs-identifier hs-type">tcInstSuperSkolTyVarsX</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-543"></span><span class="hs-comment">-- See Note [Skolemising type variables]</span><span>
</span><span id="line-544"></span><span id="tcInstSuperSkolTyVarsX"><span class="annot"><span class="annottext">tcInstSuperSkolTyVarsX :: TCvSubst -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstSuperSkolTyVarsX"><span class="hs-identifier hs-var hs-var">tcInstSuperSkolTyVarsX</span></a></span></span><span> </span><span id="local-6989586621681091518"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091518"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TCvSubst -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstSkolTyVarsPushLevel"><span class="hs-identifier hs-var">tcInstSkolTyVarsPushLevel</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091518"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-545"></span><span>
</span><span id="line-546"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstSkolTyVarsPushLevel"><span class="hs-identifier hs-type">tcInstSkolTyVarsPushLevel</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-547"></span><span>                          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-548"></span><span class="hs-comment">-- Skolemise one level deeper, hence pushTcLevel</span><span>
</span><span id="line-549"></span><span class="hs-comment">-- See Note [Skolemising type variables]</span><span>
</span><span id="line-550"></span><span id="tcInstSkolTyVarsPushLevel"><span class="annot"><span class="annottext">tcInstSkolTyVarsPushLevel :: Bool -&gt; TCvSubst -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstSkolTyVarsPushLevel"><span class="hs-identifier hs-var hs-var">tcInstSkolTyVarsPushLevel</span></a></span></span><span> </span><span id="local-6989586621681091517"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681091517"><span class="hs-identifier hs-var">overlappable</span></a></span></span><span> </span><span id="local-6989586621681091516"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091516"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621681091515"><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091515"><span class="hs-identifier hs-var">tvs</span></a></span></span><span>
</span><span id="line-551"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681091514"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681091514"><span class="hs-identifier hs-var">tc_lvl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TcLevel
</span><a href="GHC.Tc.Utils.Monad.html#getTcLevel"><span class="hs-identifier hs-var">getTcLevel</span></a></span><span>
</span><span id="line-552"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681091512"><span class="annot"><span class="annottext">pushed_lvl :: TcLevel
</span><a href="#local-6989586621681091512"><span class="hs-identifier hs-var hs-var">pushed_lvl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; TcLevel
</span><a href="GHC.Tc.Utils.TcType.html#pushTcLevel"><span class="hs-identifier hs-var">pushTcLevel</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681091514"><span class="hs-identifier hs-var">tc_lvl</span></a></span><span>
</span><span id="line-553"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; Bool -&gt; TCvSubst -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstSkolTyVarsAt"><span class="hs-identifier hs-var">tcInstSkolTyVarsAt</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681091512"><span class="hs-identifier hs-var">pushed_lvl</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681091517"><span class="hs-identifier hs-var">overlappable</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091516"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091515"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-554"></span><span>
</span><span id="line-555"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcInstSkolTyVarsAt"><span class="hs-identifier hs-type">tcInstSkolTyVarsAt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcLevel"><span class="hs-identifier hs-type">TcLevel</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-556"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-557"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-558"></span><span id="tcInstSkolTyVarsAt"><span class="annot"><span class="annottext">tcInstSkolTyVarsAt :: TcLevel -&gt; Bool -&gt; TCvSubst -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstSkolTyVarsAt"><span class="hs-identifier hs-var hs-var">tcInstSkolTyVarsAt</span></a></span></span><span> </span><span id="local-6989586621681091510"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681091510"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span id="local-6989586621681091509"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681091509"><span class="hs-identifier hs-var">overlappable</span></a></span></span><span> </span><span id="local-6989586621681091508"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091508"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621681091507"><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091507"><span class="hs-identifier hs-var">tvs</span></a></span></span><span>
</span><span id="line-559"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Type -&gt; DFunId)
-&gt; TCvSubst -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#freshenTyCoVarsX"><span class="hs-identifier hs-var">freshenTyCoVarsX</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Type -&gt; DFunId
</span><a href="#local-6989586621681091505"><span class="hs-identifier hs-var">new_skol_tv</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091508"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091507"><span class="hs-identifier hs-var">tvs</span></a></span><span>
</span><span id="line-560"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-561"></span><span>    </span><span id="local-6989586621681091504"><span class="annot"><span class="annottext">details :: TcTyVarDetails
</span><a href="#local-6989586621681091504"><span class="hs-identifier hs-var hs-var">details</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; Bool -&gt; TcTyVarDetails
</span><a href="GHC.Tc.Utils.TcType.html#SkolemTv"><span class="hs-identifier hs-var">SkolemTv</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681091510"><span class="hs-identifier hs-var">lvl</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681091509"><span class="hs-identifier hs-var">overlappable</span></a></span><span>
</span><span id="line-562"></span><span>    </span><span id="local-6989586621681091505"><span class="annot"><span class="annottext">new_skol_tv :: Name -&gt; Type -&gt; DFunId
</span><a href="#local-6989586621681091505"><span class="hs-identifier hs-var hs-var">new_skol_tv</span></a></span></span><span> </span><span id="local-6989586621681091502"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681091502"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621681091501"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091501"><span class="hs-identifier hs-var">kind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Type -&gt; TcTyVarDetails -&gt; DFunId
</span><a href="GHC.Types.Var.html#mkTcTyVar"><span class="hs-identifier hs-var">mkTcTyVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681091502"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091501"><span class="hs-identifier hs-var">kind</span></a></span><span> </span><span class="annot"><span class="annottext">TcTyVarDetails
</span><a href="#local-6989586621681091504"><span class="hs-identifier hs-var">details</span></a></span><span>
</span><span id="line-563"></span><span>
</span><span id="line-564"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-565"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#freshenTyVarBndrs"><span class="hs-identifier hs-type">freshenTyVarBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-566"></span><span class="hs-comment">-- ^ Give fresh uniques to a bunch of TyVars, but they stay</span><span>
</span><span id="line-567"></span><span class="hs-comment">--   as TyVars, rather than becoming TcTyVars</span><span>
</span><span id="line-568"></span><span class="hs-comment">-- Used in 'GHC.Tc.Instance.Family.newFamInst', and 'GHC.Tc.Utils.Instantiate.newClsInst'</span><span>
</span><span id="line-569"></span><span id="freshenTyVarBndrs"><span class="annot"><span class="annottext">freshenTyVarBndrs :: [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#freshenTyVarBndrs"><span class="hs-identifier hs-var hs-var">freshenTyVarBndrs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Type -&gt; DFunId) -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#freshenTyCoVars"><span class="hs-identifier hs-var">freshenTyCoVars</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Type -&gt; DFunId
</span><a href="GHC.Types.Var.html#mkTyVar"><span class="hs-identifier hs-var">mkTyVar</span></a></span><span>
</span><span id="line-570"></span><span>
</span><span id="line-571"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#freshenCoVarBndrsX"><span class="hs-identifier hs-type">freshenCoVarBndrsX</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#CoVar"><span class="hs-identifier hs-type">CoVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-572"></span><span class="hs-comment">-- ^ Give fresh uniques to a bunch of CoVars</span><span>
</span><span id="line-573"></span><span class="hs-comment">-- Used in &quot;GHC.Tc.Instance.Family.newFamInst&quot;</span><span>
</span><span id="line-574"></span><span id="freshenCoVarBndrsX"><span class="annot"><span class="annottext">freshenCoVarBndrsX :: TCvSubst -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#freshenCoVarBndrsX"><span class="hs-identifier hs-var hs-var">freshenCoVarBndrsX</span></a></span></span><span> </span><span id="local-6989586621681091497"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091497"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Type -&gt; DFunId)
-&gt; TCvSubst -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#freshenTyCoVarsX"><span class="hs-identifier hs-var">freshenTyCoVarsX</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Type -&gt; DFunId
</span><a href="GHC.Types.Var.html#mkCoVar"><span class="hs-identifier hs-var">mkCoVar</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091497"><span class="hs-identifier hs-var">subst</span></a></span><span>
</span><span id="line-575"></span><span>
</span><span id="line-576"></span><span class="hs-comment">------------------</span><span>
</span><span id="line-577"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#freshenTyCoVars"><span class="hs-identifier hs-type">freshenTyCoVars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Kind"><span class="hs-identifier hs-type">Kind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-578"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-579"></span><span id="freshenTyCoVars"><span class="annot"><span class="annottext">freshenTyCoVars :: (Name -&gt; Type -&gt; DFunId) -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#freshenTyCoVars"><span class="hs-identifier hs-var hs-var">freshenTyCoVars</span></a></span></span><span> </span><span id="local-6989586621681091493"><span class="annot"><span class="annottext">Name -&gt; Type -&gt; DFunId
</span><a href="#local-6989586621681091493"><span class="hs-identifier hs-var">mk_tcv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Type -&gt; DFunId)
-&gt; TCvSubst -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#freshenTyCoVarsX"><span class="hs-identifier hs-var">freshenTyCoVarsX</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Type -&gt; DFunId
</span><a href="#local-6989586621681091493"><span class="hs-identifier hs-var">mk_tcv</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#emptyTCvSubst"><span class="hs-identifier hs-var">emptyTCvSubst</span></a></span><span>
</span><span id="line-580"></span><span>
</span><span id="line-581"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#freshenTyCoVarsX"><span class="hs-identifier hs-type">freshenTyCoVarsX</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Kind"><span class="hs-identifier hs-type">Kind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-582"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-583"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-584"></span><span id="freshenTyCoVarsX"><span class="annot"><span class="annottext">freshenTyCoVarsX :: (Name -&gt; Type -&gt; DFunId)
-&gt; TCvSubst -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#freshenTyCoVarsX"><span class="hs-identifier hs-var hs-var">freshenTyCoVarsX</span></a></span></span><span> </span><span id="local-6989586621681091492"><span class="annot"><span class="annottext">Name -&gt; Type -&gt; DFunId
</span><a href="#local-6989586621681091492"><span class="hs-identifier hs-var">mk_tcv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TCvSubst
 -&gt; DFunId -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, DFunId))
-&gt; TCvSubst -&gt; [DFunId] -&gt; TcM (TCvSubst, [DFunId])
forall (m :: * -&gt; *) acc x y.
Monad m =&gt;
(acc -&gt; x -&gt; m (acc, y)) -&gt; acc -&gt; [x] -&gt; m (acc, [y])
</span><a href="GHC.Utils.Monad.html#mapAccumLM"><span class="hs-identifier hs-var">mapAccumLM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Name -&gt; Type -&gt; DFunId)
-&gt; TCvSubst
-&gt; DFunId
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, DFunId)
</span><a href="GHC.Tc.Utils.Instantiate.html#freshenTyCoVarX"><span class="hs-identifier hs-var">freshenTyCoVarX</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Type -&gt; DFunId
</span><a href="#local-6989586621681091492"><span class="hs-identifier hs-var">mk_tcv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-585"></span><span>
</span><span id="line-586"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#freshenTyCoVarX"><span class="hs-identifier hs-type">freshenTyCoVarX</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Kind"><span class="hs-identifier hs-type">Kind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-587"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyCoVar"><span class="hs-identifier hs-type">TyCoVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-588"></span><span class="hs-comment">-- This a complete freshening operation:</span><span>
</span><span id="line-589"></span><span class="hs-comment">-- the skolems have a fresh unique, and a location from the monad</span><span>
</span><span id="line-590"></span><span class="hs-comment">-- See Note [Skolemising type variables]</span><span>
</span><span id="line-591"></span><span id="freshenTyCoVarX"><span class="annot"><span class="annottext">freshenTyCoVarX :: (Name -&gt; Type -&gt; DFunId)
-&gt; TCvSubst
-&gt; DFunId
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, DFunId)
</span><a href="GHC.Tc.Utils.Instantiate.html#freshenTyCoVarX"><span class="hs-identifier hs-var hs-var">freshenTyCoVarX</span></a></span></span><span> </span><span id="local-6989586621681091490"><span class="annot"><span class="annottext">Name -&gt; Type -&gt; DFunId
</span><a href="#local-6989586621681091490"><span class="hs-identifier hs-var">mk_tcv</span></a></span></span><span> </span><span id="local-6989586621681091489"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091489"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span id="local-6989586621681091488"><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091488"><span class="hs-identifier hs-var">tycovar</span></a></span></span><span>
</span><span id="line-592"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681091487"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681091487"><span class="hs-identifier hs-var">loc</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn SrcSpan
</span><a href="GHC.Tc.Utils.Monad.html#getSrcSpanM"><span class="hs-identifier hs-var">getSrcSpanM</span></a></span><span>
</span><span id="line-593"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681091485"><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681091485"><span class="hs-identifier hs-var">uniq</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv Unique
forall gbl lcl. TcRnIf gbl lcl Unique
</span><a href="GHC.Tc.Utils.Monad.html#newUnique"><span class="hs-identifier hs-var">newUnique</span></a></span><span>
</span><span id="line-594"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681091483"><span class="annot"><span class="annottext">old_name :: Name
</span><a href="#local-6989586621681091483"><span class="hs-identifier hs-var hs-var">old_name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DFunId -&gt; Name
</span><a href="GHC.Types.Var.html#tyVarName"><span class="hs-identifier hs-var">tyVarName</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091488"><span class="hs-identifier hs-var">tycovar</span></a></span><span>
</span><span id="line-595"></span><span>             </span><span class="hs-comment">-- Force so we don't retain reference to the old name and id</span><span>
</span><span id="line-596"></span><span>             </span><span class="hs-comment">-- See (#19619) for more discussion</span><span>
</span><span id="line-597"></span><span>             </span><span class="hs-glyph">!</span><span id="local-6989586621681091480"><span class="annot"><span class="annottext">old_occ_name :: OccName
</span><a href="#local-6989586621681091480"><span class="hs-identifier hs-var hs-var">old_occ_name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; OccName
forall a. NamedThing a =&gt; a -&gt; OccName
</span><a href="GHC.Types.Name.html#getOccName"><span class="hs-identifier hs-var">getOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681091483"><span class="hs-identifier hs-var">old_name</span></a></span><span>
</span><span id="line-598"></span><span>             </span><span id="local-6989586621681091478"><span class="annot"><span class="annottext">new_name :: Name
</span><a href="#local-6989586621681091478"><span class="hs-identifier hs-var hs-var">new_name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Unique -&gt; OccName -&gt; SrcSpan -&gt; Name
</span><a href="GHC.Types.Name.html#mkInternalName"><span class="hs-identifier hs-var">mkInternalName</span></a></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681091485"><span class="hs-identifier hs-var">uniq</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681091480"><span class="hs-identifier hs-var">old_occ_name</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681091487"><span class="hs-identifier hs-var">loc</span></a></span><span>
</span><span id="line-599"></span><span>             </span><span id="local-6989586621681091476"><span class="annot"><span class="annottext">new_kind :: Type
</span><a href="#local-6989586621681091476"><span class="hs-identifier hs-var hs-var">new_kind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyUnchecked"><span class="hs-identifier hs-var">substTyUnchecked</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091489"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DFunId -&gt; Type
</span><a href="GHC.Types.Var.html#tyVarKind"><span class="hs-identifier hs-var">tyVarKind</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091488"><span class="hs-identifier hs-var">tycovar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-600"></span><span>             </span><span id="local-6989586621681091475"><span class="annot"><span class="annottext">new_tcv :: DFunId
</span><a href="#local-6989586621681091475"><span class="hs-identifier hs-var hs-var">new_tcv</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Type -&gt; DFunId
</span><a href="#local-6989586621681091490"><span class="hs-identifier hs-var">mk_tcv</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681091478"><span class="hs-identifier hs-var">new_name</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091476"><span class="hs-identifier hs-var">new_kind</span></a></span><span>
</span><span id="line-601"></span><span>             </span><span id="local-6989586621681091474"><span class="annot"><span class="annottext">subst1 :: TCvSubst
</span><a href="#local-6989586621681091474"><span class="hs-identifier hs-var hs-var">subst1</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TCvSubst -&gt; DFunId -&gt; DFunId -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#extendTCvSubstWithClone"><span class="hs-identifier hs-var">extendTCvSubstWithClone</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091489"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091488"><span class="hs-identifier hs-var">tycovar</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091475"><span class="hs-identifier hs-var">new_tcv</span></a></span><span>
</span><span id="line-602"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TCvSubst, DFunId)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TCvSubst, DFunId)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091474"><span class="hs-identifier hs-var">subst1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091475"><span class="hs-identifier hs-var">new_tcv</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-603"></span><span>
</span><span id="line-604"></span><span class="hs-comment">{- Note [Skolemising type variables]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The tcInstSkolTyVars family of functions instantiate a list of TyVars
to fresh skolem TcTyVars. Important notes:

a) Level allocation. We generally skolemise /before/ calling
   pushLevelAndCaptureConstraints.  So we want their level to the level
   of the soon-to-be-created implication, which has a level ONE HIGHER
   than the current level.  Hence the pushTcLevel.  It feels like a
   slight hack.

b) The [TyVar] should be ordered (kind vars first)
   See Note [Kind substitution when instantiating]

c) It's a complete freshening operation: the skolems have a fresh
   unique, and a location from the monad

d) The resulting skolems are
        non-overlappable for tcInstSkolTyVars,
   but overlappable for tcInstSuperSkolTyVars
   See GHC.Tc.Deriv.Infer Note [Overlap and deriving] for an example
   of where this matters.

Note [Kind substitution when instantiating]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When we instantiate a bunch of kind and type variables, first we
expect them to be topologically sorted.
Then we have to instantiate the kind variables, build a substitution
from old variables to the new variables, then instantiate the type
variables substituting the original kind.

Exemple: If we want to instantiate
  [(k1 :: *), (k2 :: *), (a :: k1 -&gt; k2), (b :: k1)]
we want
  [(?k1 :: *), (?k2 :: *), (?a :: ?k1 -&gt; ?k2), (?b :: ?k1)]
instead of the bogus
  [(?k1 :: *), (?k2 :: *), (?a :: k1 -&gt; k2), (?b :: k1)]
-}</span><span>
</span><span id="line-642"></span><span>
</span><span id="line-643"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
                Literals
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-648"></span><span>
</span><span id="line-649"></span><span class="hs-comment">{-
In newOverloadedLit we convert directly to an Int or Integer if we
know that's what we want.  This may save some time, by not
temporarily generating overloaded literals, but it won't catch all
cases (the rest are caught in lookupInst).

-}</span><span>
</span><span id="line-656"></span><span>
</span><span id="line-657"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#newOverloadedLit"><span class="hs-identifier hs-type">newOverloadedLit</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Lit.html#HsOverLit"><span class="hs-identifier hs-type">HsOverLit</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span>
</span><span id="line-658"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpRhoType"><span class="hs-identifier hs-type">ExpRhoType</span></a></span><span>
</span><span id="line-659"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Lit.html#HsOverLit"><span class="hs-identifier hs-type">HsOverLit</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-660"></span><span id="newOverloadedLit"><span class="annot"><span class="annottext">newOverloadedLit :: HsOverLit GhcRn -&gt; ExpRhoType -&gt; TcM (HsOverLit GhcTc)
</span><a href="GHC.Tc.Utils.Instantiate.html#newOverloadedLit"><span class="hs-identifier hs-var hs-var">newOverloadedLit</span></a></span></span><span>
</span><span id="line-661"></span><span>  </span><span id="local-6989586621681091472"><span class="annot"><span class="annottext">lit :: HsOverLit GhcRn
</span><a href="#local-6989586621681091472"><span class="hs-identifier hs-var">lit</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Lit.html#OverLit"><span class="hs-identifier hs-type">OverLit</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ol_val :: forall p. HsOverLit p -&gt; OverLitVal
</span><a href="GHC.Hs.Lit.html#ol_val"><span class="hs-identifier hs-var">ol_val</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681091469"><span class="annot"><span class="annottext">OverLitVal
</span><a href="#local-6989586621681091469"><span class="hs-identifier hs-var">val</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ol_ext :: forall p. HsOverLit p -&gt; XOverLit p
</span><a href="GHC.Hs.Lit.html#ol_ext"><span class="hs-identifier hs-var">ol_ext</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681091467"><span class="annot"><span class="annottext">XOverLit GhcRn
</span><a href="#local-6989586621681091467"><span class="hs-identifier hs-var">rebindable</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681091466"><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681091466"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span>
</span><span id="line-662"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
XOverLit GhcRn
</span><a href="#local-6989586621681091467"><span class="hs-identifier hs-var">rebindable</span></a></span><span>
</span><span id="line-663"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681091465"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091465"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ExpRhoType -&gt; TcM Type
</span><a href="GHC.Tc.Utils.TcMType.html#expTypeToType"><span class="hs-identifier hs-var">expTypeToType</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681091466"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-664"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681091463"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681091463"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-665"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681091461"><span class="annot"><span class="annottext">platform :: Platform
</span><a href="#local-6989586621681091461"><span class="hs-identifier hs-var hs-var">platform</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Platform
</span><a href="GHC.Driver.Session.html#targetPlatform"><span class="hs-identifier hs-var hs-var">targetPlatform</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681091463"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-666"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Platform -&gt; OverLitVal -&gt; Type -&gt; Maybe (HsExpr GhcTc)
</span><a href="GHC.Tc.Utils.Zonk.html#shortCutLit"><span class="hs-identifier hs-var">shortCutLit</span></a></span><span> </span><span class="annot"><span class="annottext">Platform
</span><a href="#local-6989586621681091461"><span class="hs-identifier hs-var">platform</span></a></span><span> </span><span class="annot"><span class="annottext">OverLitVal
</span><a href="#local-6989586621681091469"><span class="hs-identifier hs-var">val</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091465"><span class="hs-identifier hs-var">res_ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-667"></span><span>        </span><span class="hs-comment">-- Do not generate a LitInst for rebindable syntax.</span><span>
</span><span id="line-668"></span><span>        </span><span class="hs-comment">-- Reason: If we do, tcSimplify will call lookupInst, which</span><span>
</span><span id="line-669"></span><span>        </span><span class="hs-comment">--         will call tcSyntaxName, which does unification,</span><span>
</span><span id="line-670"></span><span>        </span><span class="hs-comment">--         which tcSimplify doesn't like</span><span>
</span><span id="line-671"></span><span>           </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681091458"><span class="annot"><span class="annottext">HsExpr GhcTc
</span><a href="#local-6989586621681091458"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">HsOverLit GhcTc -&gt; TcM (HsOverLit GhcTc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsOverLit GhcRn
</span><a href="#local-6989586621681091472"><span class="hs-identifier hs-var">lit</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ol_witness :: HsExpr GhcTc
</span><a href="GHC.Hs.Lit.html#ol_witness"><span class="hs-identifier hs-var">ol_witness</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsExpr GhcTc
</span><a href="#local-6989586621681091458"><span class="hs-identifier hs-var">expr</span></a></span><span>
</span><span id="line-672"></span><span>                                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ol_ext :: XOverLit GhcTc
</span><a href="GHC.Hs.Lit.html#ol_ext"><span class="hs-identifier hs-var">ol_ext</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Type -&gt; OverLitTc
</span><a href="GHC.Hs.Lit.html#OverLitTc"><span class="hs-identifier hs-var">OverLitTc</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091465"><span class="hs-identifier hs-var">res_ty</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-673"></span><span>           </span><span class="annot"><span class="annottext">Maybe (HsExpr GhcTc)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; HsOverLit GhcRn -&gt; ExpRhoType -&gt; TcM (HsOverLit GhcTc)
</span><a href="GHC.Tc.Utils.Instantiate.html#newNonTrivialOverloadedLit"><span class="hs-identifier hs-var">newNonTrivialOverloadedLit</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091454"><span class="hs-identifier hs-var">orig</span></a></span><span> </span><span class="annot"><span class="annottext">HsOverLit GhcRn
</span><a href="#local-6989586621681091472"><span class="hs-identifier hs-var">lit</span></a></span><span>
</span><span id="line-674"></span><span>                                                   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; ExpRhoType
</span><a href="GHC.Tc.Utils.TcType.html#mkCheckExpType"><span class="hs-identifier hs-var">mkCheckExpType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091465"><span class="hs-identifier hs-var">res_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-675"></span><span>
</span><span id="line-676"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-677"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; HsOverLit GhcRn -&gt; ExpRhoType -&gt; TcM (HsOverLit GhcTc)
</span><a href="GHC.Tc.Utils.Instantiate.html#newNonTrivialOverloadedLit"><span class="hs-identifier hs-var">newNonTrivialOverloadedLit</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091454"><span class="hs-identifier hs-var">orig</span></a></span><span> </span><span class="annot"><span class="annottext">HsOverLit GhcRn
</span><a href="#local-6989586621681091472"><span class="hs-identifier hs-var">lit</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681091466"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-678"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-679"></span><span>    </span><span id="local-6989586621681091454"><span class="annot"><span class="annottext">orig :: CtOrigin
</span><a href="#local-6989586621681091454"><span class="hs-identifier hs-var hs-var">orig</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsOverLit GhcRn -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#LiteralOrigin"><span class="hs-identifier hs-var">LiteralOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">HsOverLit GhcRn
</span><a href="#local-6989586621681091472"><span class="hs-identifier hs-var">lit</span></a></span><span>
</span><span id="line-680"></span><span>
</span><span id="line-681"></span><span class="hs-comment">-- Does not handle things that 'shortCutLit' can handle. See also</span><span>
</span><span id="line-682"></span><span class="hs-comment">-- newOverloadedLit in GHC.Tc.Utils.Unify</span><span>
</span><span id="line-683"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#newNonTrivialOverloadedLit"><span class="hs-identifier hs-type">newNonTrivialOverloadedLit</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span>
</span><span id="line-684"></span><span>                           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Lit.html#HsOverLit"><span class="hs-identifier hs-type">HsOverLit</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span>
</span><span id="line-685"></span><span>                           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#ExpRhoType"><span class="hs-identifier hs-type">ExpRhoType</span></a></span><span>
</span><span id="line-686"></span><span>                           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Lit.html#HsOverLit"><span class="hs-identifier hs-type">HsOverLit</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-687"></span><span id="newNonTrivialOverloadedLit"><span class="annot"><span class="annottext">newNonTrivialOverloadedLit :: CtOrigin -&gt; HsOverLit GhcRn -&gt; ExpRhoType -&gt; TcM (HsOverLit GhcTc)
</span><a href="GHC.Tc.Utils.Instantiate.html#newNonTrivialOverloadedLit"><span class="hs-identifier hs-var hs-var">newNonTrivialOverloadedLit</span></a></span></span><span> </span><span id="local-6989586621681091451"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091451"><span class="hs-identifier hs-var">orig</span></a></span></span><span>
</span><span id="line-688"></span><span>  </span><span id="local-6989586621681091450"><span class="annot"><span class="annottext">lit :: HsOverLit GhcRn
</span><a href="#local-6989586621681091450"><span class="hs-identifier hs-var">lit</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Lit.html#OverLit"><span class="hs-identifier hs-type">OverLit</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ol_val :: forall p. HsOverLit p -&gt; OverLitVal
</span><a href="GHC.Hs.Lit.html#ol_val"><span class="hs-identifier hs-var">ol_val</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681091449"><span class="annot"><span class="annottext">OverLitVal
</span><a href="#local-6989586621681091449"><span class="hs-identifier hs-var">val</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ol_witness :: forall p. HsOverLit p -&gt; HsExpr p
</span><a href="GHC.Hs.Lit.html#ol_witness"><span class="hs-identifier hs-var">ol_witness</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#HsVar"><span class="hs-identifier hs-type">HsVar</span></a></span><span> </span><span class="annot"><span class="annottext">XVar GhcRn
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681091447"><span class="annot"><span class="annottext">IdP GhcRn
</span><a href="#local-6989586621681091447"><span class="hs-identifier hs-var">meth_name</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-689"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ol_ext :: forall p. HsOverLit p -&gt; XOverLit p
</span><a href="GHC.Hs.Lit.html#ol_ext"><span class="hs-identifier hs-var">ol_ext</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681091446"><span class="annot"><span class="annottext">XOverLit GhcRn
</span><a href="#local-6989586621681091446"><span class="hs-identifier hs-var">rebindable</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span id="local-6989586621681091445"><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681091445"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span>
</span><span id="line-690"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681091444"><span class="annot"><span class="annottext">HsLit GhcTc
</span><a href="#local-6989586621681091444"><span class="hs-identifier hs-var">hs_lit</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">OverLitVal -&gt; TcM (HsLit GhcTc)
</span><a href="GHC.Tc.Utils.Instantiate.html#mkOverLit"><span class="hs-identifier hs-var">mkOverLit</span></a></span><span> </span><span class="annot"><span class="annottext">OverLitVal
</span><a href="#local-6989586621681091449"><span class="hs-identifier hs-var">val</span></a></span><span>
</span><span id="line-691"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681091443"><span class="annot"><span class="annottext">lit_ty :: Type
</span><a href="#local-6989586621681091443"><span class="hs-identifier hs-var hs-var">lit_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsLit GhcTc -&gt; Type
forall (p :: Pass). HsLit (GhcPass p) -&gt; Type
</span><a href="GHC.Tc.Utils.Zonk.html#hsLitType"><span class="hs-identifier hs-var">hsLitType</span></a></span><span> </span><span class="annot"><span class="annottext">HsLit GhcTc
</span><a href="#local-6989586621681091444"><span class="hs-identifier hs-var">hs_lit</span></a></span><span>
</span><span id="line-692"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">()
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091441"><span class="annot"><span class="annottext">SyntaxExprTc
</span><a href="#local-6989586621681091441"><span class="hs-identifier hs-var">fi'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin
-&gt; SyntaxExprRn
-&gt; [SyntaxOpType]
-&gt; ExpRhoType
-&gt; (ThetaType -&gt; ThetaType -&gt; TcRn ())
-&gt; TcM ((), SyntaxExprTc)
forall a.
CtOrigin
-&gt; SyntaxExprRn
-&gt; [SyntaxOpType]
-&gt; ExpRhoType
-&gt; (ThetaType -&gt; ThetaType -&gt; TcM a)
-&gt; TcM (a, SyntaxExprTc)
</span><a href="GHC.Tc.Gen.Expr.html#tcSyntaxOp"><span class="hs-identifier hs-var">tcSyntaxOp</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091451"><span class="hs-identifier hs-var">orig</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; SyntaxExprRn
</span><a href="GHC.Hs.Expr.html#mkRnSyntaxExpr"><span class="hs-identifier hs-var">mkRnSyntaxExpr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
IdP GhcRn
</span><a href="#local-6989586621681091447"><span class="hs-identifier hs-var">meth_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-693"></span><span>                                      </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type -&gt; SyntaxOpType
</span><a href="GHC.Tc.Utils.TcType.html#synKnownType"><span class="hs-identifier hs-var">synKnownType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091443"><span class="hs-identifier hs-var">lit_ty</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681091445"><span class="hs-identifier hs-var">res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">((ThetaType -&gt; ThetaType -&gt; TcRn ()) -&gt; TcM ((), SyntaxExprTc))
-&gt; (ThetaType -&gt; ThetaType -&gt; TcRn ()) -&gt; TcM ((), SyntaxExprTc)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-694"></span><span>                      </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">ThetaType
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">() -&gt; TcRn ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-695"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681091438"><span class="annot"><span class="annottext">HsExpr GhcTc
</span><a href="#local-6989586621681091438"><span class="hs-identifier hs-var">witness</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SyntaxExprTc
-&gt; [GenLocated SrcSpan (HsExpr GhcTc)]
-&gt; GenLocated SrcSpan (HsExpr GhcTc)
</span><a href="GHC.Hs.Utils.html#nlHsSyntaxApps"><span class="hs-identifier hs-var">nlHsSyntaxApps</span></a></span><span> </span><span class="annot"><span class="annottext">SyntaxExprTc
</span><a href="#local-6989586621681091441"><span class="hs-identifier hs-var">fi'</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">HsLit GhcTc -&gt; GenLocated SrcSpan (HsExpr GhcTc)
forall (p :: Pass). HsLit (GhcPass p) -&gt; LHsExpr (GhcPass p)
</span><a href="GHC.Hs.Utils.html#nlHsLit"><span class="hs-identifier hs-var">nlHsLit</span></a></span><span> </span><span class="annot"><span class="annottext">HsLit GhcTc
</span><a href="#local-6989586621681091444"><span class="hs-identifier hs-var">hs_lit</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-696"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681091435"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091435"><span class="hs-identifier hs-var">res_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ExpRhoType -&gt; TcM Type
</span><a href="GHC.Tc.Utils.TcMType.html#readExpType"><span class="hs-identifier hs-var">readExpType</span></a></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><a href="#local-6989586621681091445"><span class="hs-identifier hs-var">res_ty</span></a></span><span>
</span><span id="line-697"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HsOverLit GhcTc -&gt; TcM (HsOverLit GhcTc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsOverLit GhcRn
</span><a href="#local-6989586621681091450"><span class="hs-identifier hs-var">lit</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ol_witness :: HsExpr GhcTc
</span><a href="GHC.Hs.Lit.html#ol_witness"><span class="hs-identifier hs-var">ol_witness</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsExpr GhcTc
</span><a href="#local-6989586621681091438"><span class="hs-identifier hs-var">witness</span></a></span><span>
</span><span id="line-698"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ol_ext :: XOverLit GhcTc
</span><a href="GHC.Hs.Lit.html#ol_ext"><span class="hs-identifier hs-var">ol_ext</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Type -&gt; OverLitTc
</span><a href="GHC.Hs.Lit.html#OverLitTc"><span class="hs-identifier hs-var">OverLitTc</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
XOverLit GhcRn
</span><a href="#local-6989586621681091446"><span class="hs-identifier hs-var">rebindable</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091435"><span class="hs-identifier hs-var">res_ty</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-699"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#newNonTrivialOverloadedLit"><span class="hs-identifier hs-var">newNonTrivialOverloadedLit</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681091433"><span class="annot"><span class="annottext">HsOverLit GhcRn
</span><a href="#local-6989586621681091433"><span class="hs-identifier hs-var">lit</span></a></span></span><span> </span><span class="annot"><span class="annottext">ExpRhoType
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-700"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM (HsOverLit GhcTc)
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;newNonTrivialOverloadedLit&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsOverLit GhcRn -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">HsOverLit GhcRn
</span><a href="#local-6989586621681091433"><span class="hs-identifier hs-var">lit</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-701"></span><span>
</span><span id="line-702"></span><span class="hs-comment">------------</span><span>
</span><span id="line-703"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#mkOverLit"><span class="hs-identifier hs-type">mkOverLit</span></a></span><span> </span><span class="hs-glyph">::</span><span class="annot"><a href="GHC.Hs.Lit.html#OverLitVal"><span class="hs-identifier hs-type">OverLitVal</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Lit.html#HsLit"><span class="hs-identifier hs-type">HsLit</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-704"></span><span id="mkOverLit"><span class="annot"><span class="annottext">mkOverLit :: OverLitVal -&gt; TcM (HsLit GhcTc)
</span><a href="GHC.Tc.Utils.Instantiate.html#mkOverLit"><span class="hs-identifier hs-var hs-var">mkOverLit</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Lit.html#HsIntegral"><span class="hs-identifier hs-type">HsIntegral</span></a></span><span> </span><span id="local-6989586621681091431"><span class="annot"><span class="annottext">IntegralLit
</span><a href="#local-6989586621681091431"><span class="hs-identifier hs-var">i</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-705"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681091430"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091430"><span class="hs-identifier hs-var">integer_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM Type
</span><a href="GHC.Tc.Utils.Env.html#tcMetaTy"><span class="hs-identifier hs-var">tcMetaTy</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="GHC.Builtin.Types.html#integerTyConName"><span class="hs-identifier hs-var">integerTyConName</span></a></span><span>
</span><span id="line-706"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HsLit GhcTc -&gt; TcM (HsLit GhcTc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XHsInteger GhcTc -&gt; Integer -&gt; Type -&gt; HsLit GhcTc
forall x. XHsInteger x -&gt; Integer -&gt; Type -&gt; HsLit x
</span><a href="GHC.Hs.Lit.html#HsInteger"><span class="hs-identifier hs-var">HsInteger</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IntegralLit -&gt; SourceText
</span><a href="GHC.Types.Basic.html#il_text"><span class="hs-identifier hs-var hs-var">il_text</span></a></span><span> </span><span class="annot"><span class="annottext">IntegralLit
</span><a href="#local-6989586621681091431"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-707"></span><span>                            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IntegralLit -&gt; Integer
</span><a href="GHC.Types.Basic.html#il_value"><span class="hs-identifier hs-var hs-var">il_value</span></a></span><span> </span><span class="annot"><span class="annottext">IntegralLit
</span><a href="#local-6989586621681091431"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091430"><span class="hs-identifier hs-var">integer_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-708"></span><span>
</span><span id="line-709"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#mkOverLit"><span class="hs-identifier hs-var">mkOverLit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Lit.html#HsFractional"><span class="hs-identifier hs-type">HsFractional</span></a></span><span> </span><span id="local-6989586621681091424"><span class="annot"><span class="annottext">FractionalLit
</span><a href="#local-6989586621681091424"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-710"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681091423"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091423"><span class="hs-identifier hs-var">rat_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM Type
</span><a href="GHC.Tc.Utils.Env.html#tcMetaTy"><span class="hs-identifier hs-var">tcMetaTy</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="GHC.Builtin.Names.html#rationalTyConName"><span class="hs-identifier hs-var">rationalTyConName</span></a></span><span>
</span><span id="line-711"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">HsLit GhcTc -&gt; TcM (HsLit GhcTc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XHsRat GhcTc -&gt; FractionalLit -&gt; Type -&gt; HsLit GhcTc
forall x. XHsRat x -&gt; FractionalLit -&gt; Type -&gt; HsLit x
</span><a href="GHC.Hs.Lit.html#HsRat"><span class="hs-identifier hs-var">HsRat</span></a></span><span> </span><span class="annot"><span class="annottext">NoExtField
XHsRat GhcTc
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span> </span><span class="annot"><span class="annottext">FractionalLit
</span><a href="#local-6989586621681091424"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091423"><span class="hs-identifier hs-var">rat_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-712"></span><span>
</span><span id="line-713"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#mkOverLit"><span class="hs-identifier hs-var">mkOverLit</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Lit.html#HsIsString"><span class="hs-identifier hs-type">HsIsString</span></a></span><span> </span><span id="local-6989586621681091419"><span class="annot"><span class="annottext">SourceText
</span><a href="#local-6989586621681091419"><span class="hs-identifier hs-var">src</span></a></span></span><span> </span><span id="local-6989586621681091418"><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621681091418"><span class="hs-identifier hs-var">s</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsLit GhcTc -&gt; TcM (HsLit GhcTc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XHsString GhcTc -&gt; FastString -&gt; HsLit GhcTc
forall x. XHsString x -&gt; FastString -&gt; HsLit x
</span><a href="GHC.Hs.Lit.html#HsString"><span class="hs-identifier hs-var">HsString</span></a></span><span> </span><span class="annot"><span class="annottext">SourceText
XHsString GhcTc
</span><a href="#local-6989586621681091419"><span class="hs-identifier hs-var">src</span></a></span><span> </span><span class="annot"><span class="annottext">FastString
</span><a href="#local-6989586621681091418"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-714"></span><span>
</span><span id="line-715"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                Re-mappable syntax

     Used only for arrow syntax -- find a way to nuke this
*                                                                      *
************************************************************************

Suppose we are doing the -XRebindableSyntax thing, and we encounter
a do-expression.  We have to find (&gt;&gt;) in the current environment, which is
done by the rename. Then we have to check that it has the same type as
Control.Monad.(&gt;&gt;).  Or, more precisely, a compatible type. One 'customer' had
this:

  (&gt;&gt;) :: HB m n mn =&gt; m a -&gt; n b -&gt; mn b

So the idea is to generate a local binding for (&gt;&gt;), thus:

        let then72 :: forall a b. m a -&gt; m b -&gt; m b
            then72 = ...something involving the user's (&gt;&gt;)...
        in
        ...the do-expression...

Now the do-expression can proceed using then72, which has exactly
the expected type.

In fact tcSyntaxName just generates the RHS for then72, because we only
want an actual binding in the do-expression case. For literals, we can
just use the expression inline.
-}</span><span>
</span><span id="line-746"></span><span>
</span><span id="line-747"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcSyntaxName"><span class="hs-identifier hs-type">tcSyntaxName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span>
</span><span id="line-748"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span>                 </span><span class="hs-comment">-- ^ Type to instantiate it at</span><span>
</span><span id="line-749"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">)</span><span>   </span><span class="hs-comment">-- ^ (Standard name, user name)</span><span>
</span><span id="line-750"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-751"></span><span>                                       </span><span class="hs-comment">-- ^ (Standard name, suitable expression)</span><span>
</span><span id="line-752"></span><span class="hs-comment">-- USED ONLY FOR CmdTop (sigh) ***</span><span>
</span><span id="line-753"></span><span class="hs-comment">-- See Note [CmdSyntaxTable] in &quot;GHC.Hs.Expr&quot;</span><span>
</span><span id="line-754"></span><span>
</span><span id="line-755"></span><span id="tcSyntaxName"><span class="annot"><span class="annottext">tcSyntaxName :: CtOrigin
-&gt; Type -&gt; (Name, HsExpr GhcRn) -&gt; TcM (Name, HsExpr GhcTc)
</span><a href="GHC.Tc.Utils.Instantiate.html#tcSyntaxName"><span class="hs-identifier hs-var hs-var">tcSyntaxName</span></a></span></span><span> </span><span id="local-6989586621681091416"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091416"><span class="hs-identifier hs-var">orig</span></a></span></span><span> </span><span id="local-6989586621681091415"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091415"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091414"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681091414"><span class="hs-identifier hs-var">std_nm</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#HsVar"><span class="hs-identifier hs-type">HsVar</span></a></span><span> </span><span class="annot"><span class="annottext">XVar GhcRn
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681091413"><span class="annot"><span class="annottext">IdP GhcRn
</span><a href="#local-6989586621681091413"><span class="hs-identifier hs-var">user_nm</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-756"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681091414"><span class="hs-identifier hs-var">std_nm</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Name -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Name
IdP GhcRn
</span><a href="#local-6989586621681091413"><span class="hs-identifier hs-var">user_nm</span></a></span><span>
</span><span id="line-757"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681091412"><span class="annot"><span class="annottext">HsExpr GhcTc
</span><a href="#local-6989586621681091412"><span class="hs-identifier hs-var">rhs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; Name -&gt; ThetaType -&gt; TcM (HsExpr GhcTc)
</span><a href="GHC.Tc.Utils.Instantiate.html#newMethodFromName"><span class="hs-identifier hs-var">newMethodFromName</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091416"><span class="hs-identifier hs-var">orig</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681091414"><span class="hs-identifier hs-var">std_nm</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091415"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-758"></span><span>       </span><span class="annot"><span class="annottext">(Name, HsExpr GhcTc) -&gt; TcM (Name, HsExpr GhcTc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681091414"><span class="hs-identifier hs-var">std_nm</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HsExpr GhcTc
</span><a href="#local-6989586621681091412"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-759"></span><span>
</span><span id="line-760"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcSyntaxName"><span class="hs-identifier hs-var">tcSyntaxName</span></a></span><span> </span><span id="local-6989586621681091411"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091411"><span class="hs-identifier hs-var">orig</span></a></span></span><span> </span><span id="local-6989586621681091410"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091410"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091409"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681091409"><span class="hs-identifier hs-var">std_nm</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091408"><span class="annot"><span class="annottext">HsExpr GhcRn
</span><a href="#local-6989586621681091408"><span class="hs-identifier hs-var">user_nm_expr</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-761"></span><span>    </span><span id="local-6989586621681091407"><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091407"><span class="hs-identifier hs-var">std_id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM DFunId
</span><a href="GHC.Tc.Utils.Env.html#tcLookupId"><span class="hs-identifier hs-var">tcLookupId</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681091409"><span class="hs-identifier hs-var">std_nm</span></a></span><span>
</span><span id="line-762"></span><span>    </span><span class="hs-keyword">let</span><span>
</span><span id="line-763"></span><span>        </span><span class="hs-comment">-- C.f. newMethodAtLoc</span><span>
</span><span id="line-764"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">[</span><span id="local-6989586621681091406"><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091406"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091405"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091405"><span class="hs-identifier hs-var">tau</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; ([DFunId], ThetaType, Type)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitSigmaTy"><span class="hs-identifier hs-var">tcSplitSigmaTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DFunId -&gt; Type
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091407"><span class="hs-identifier hs-var">std_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-765"></span><span>        </span><span id="local-6989586621681091402"><span class="annot"><span class="annottext">sigma1 :: Type
</span><a href="#local-6989586621681091402"><span class="hs-identifier hs-var hs-var">sigma1</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; [DFunId] -&gt; ThetaType -&gt; Type -&gt; Type
[DFunId] -&gt; ThetaType -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTyWith"><span class="hs-identifier hs-var">substTyWith</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091406"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091410"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091405"><span class="hs-identifier hs-var">tau</span></a></span><span>
</span><span id="line-766"></span><span>        </span><span class="hs-comment">-- Actually, the &quot;tau-type&quot; might be a sigma-type in the</span><span>
</span><span id="line-767"></span><span>        </span><span class="hs-comment">-- case of locally-polymorphic methods.</span><span>
</span><span id="line-768"></span><span>
</span><span id="line-769"></span><span>    </span><span class="annot"><span class="annottext">(TidyEnv -&gt; TcM (TidyEnv, SDoc))
-&gt; TcM (Name, HsExpr GhcTc) -&gt; TcM (Name, HsExpr GhcTc)
forall a. (TidyEnv -&gt; TcM (TidyEnv, SDoc)) -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#addErrCtxtM"><span class="hs-identifier hs-var">addErrCtxtM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsExpr GhcRn -&gt; CtOrigin -&gt; Type -&gt; TidyEnv -&gt; TcM (TidyEnv, SDoc)
</span><a href="GHC.Tc.Utils.Instantiate.html#syntaxNameCtxt"><span class="hs-identifier hs-var">syntaxNameCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">HsExpr GhcRn
</span><a href="#local-6989586621681091408"><span class="hs-identifier hs-var">user_nm_expr</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091411"><span class="hs-identifier hs-var">orig</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091402"><span class="hs-identifier hs-var">sigma1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcM (Name, HsExpr GhcTc) -&gt; TcM (Name, HsExpr GhcTc))
-&gt; TcM (Name, HsExpr GhcTc) -&gt; TcM (Name, HsExpr GhcTc)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-770"></span><span>
</span><span id="line-771"></span><span>        </span><span class="hs-comment">-- Check that the user-supplied thing has the</span><span>
</span><span id="line-772"></span><span>        </span><span class="hs-comment">-- same type as the standard one.</span><span>
</span><span id="line-773"></span><span>        </span><span class="hs-comment">-- Tiresome jiggling because tcCheckSigma takes a located expression</span><span>
</span><span id="line-774"></span><span>     </span><span id="local-6989586621681091398"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681091398"><span class="hs-identifier hs-var">span</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn SrcSpan
</span><a href="GHC.Tc.Utils.Monad.html#getSrcSpanM"><span class="hs-identifier hs-var">getSrcSpanM</span></a></span><span>
</span><span id="line-775"></span><span>     </span><span id="local-6989586621681091397"><span class="annot"><span class="annottext">GenLocated SrcSpan (HsExpr GhcTc)
</span><a href="#local-6989586621681091397"><span class="hs-identifier hs-var">expr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LHsExpr GhcRn -&gt; Type -&gt; TcM (GenLocated SrcSpan (HsExpr GhcTc))
</span><a href="GHC.Tc.Gen.Expr.html#tcCheckPolyExpr"><span class="hs-identifier hs-var">tcCheckPolyExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; HsExpr GhcRn -&gt; LHsExpr GhcRn
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681091398"><span class="hs-identifier hs-var">span</span></a></span><span> </span><span class="annot"><span class="annottext">HsExpr GhcRn
</span><a href="#local-6989586621681091408"><span class="hs-identifier hs-var">user_nm_expr</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091402"><span class="hs-identifier hs-var">sigma1</span></a></span><span>
</span><span id="line-776"></span><span>     </span><span class="annot"><span class="annottext">(Name, HsExpr GhcTc) -&gt; TcM (Name, HsExpr GhcTc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681091409"><span class="hs-identifier hs-var">std_nm</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan (HsExpr GhcTc) -&gt; HsExpr GhcTc
forall l e. GenLocated l e -&gt; e
</span><a href="GHC.Types.SrcLoc.html#unLoc"><span class="hs-identifier hs-var">unLoc</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan (HsExpr GhcTc)
</span><a href="#local-6989586621681091397"><span class="hs-identifier hs-var">expr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-777"></span><span>
</span><span id="line-778"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#syntaxNameCtxt"><span class="hs-identifier hs-type">syntaxNameCtxt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span>
</span><span id="line-779"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcRn"><span class="hs-identifier hs-type">TcRn</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-780"></span><span id="syntaxNameCtxt"><span class="annot"><span class="annottext">syntaxNameCtxt :: HsExpr GhcRn -&gt; CtOrigin -&gt; Type -&gt; TidyEnv -&gt; TcM (TidyEnv, SDoc)
</span><a href="GHC.Tc.Utils.Instantiate.html#syntaxNameCtxt"><span class="hs-identifier hs-var hs-var">syntaxNameCtxt</span></a></span></span><span> </span><span id="local-6989586621681091395"><span class="annot"><span class="annottext">HsExpr GhcRn
</span><a href="#local-6989586621681091395"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621681091394"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091394"><span class="hs-identifier hs-var">orig</span></a></span></span><span> </span><span id="local-6989586621681091393"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091393"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621681091392"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681091392"><span class="hs-identifier hs-var">tidy_env</span></a></span></span><span>
</span><span id="line-781"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681091391"><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681091391"><span class="hs-identifier hs-var">inst_loc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; Maybe TypeOrKind -&gt; TcM CtLoc
</span><a href="GHC.Tc.Utils.Monad.html#getCtLocM"><span class="hs-identifier hs-var">getCtLocM</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681091394"><span class="hs-identifier hs-var">orig</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TypeOrKind -&gt; Maybe TypeOrKind
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="GHC.Types.Basic.html#TypeLevel"><span class="hs-identifier hs-var">TypeLevel</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-782"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681091380"><span class="annot"><span class="annottext">msg :: SDoc
</span><a href="#local-6989586621681091380"><span class="hs-identifier hs-var hs-var">msg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;When checking that&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsExpr GhcRn -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">HsExpr GhcRn
</span><a href="#local-6989586621681091395"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-783"></span><span>                          </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;(needed by a syntactic construct)&quot;</span></span><span>
</span><span id="line-784"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;has the required type:&quot;</span></span><span>
</span><span id="line-785"></span><span>                                  </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Tidy.html#tidyType"><span class="hs-identifier hs-var">tidyType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681091392"><span class="hs-identifier hs-var">tidy_env</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681091393"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-786"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtLoc -&gt; SDoc
</span><a href="GHC.Tc.Types.Constraint.html#pprCtLoc"><span class="hs-identifier hs-var">pprCtLoc</span></a></span><span> </span><span class="annot"><span class="annottext">CtLoc
</span><a href="#local-6989586621681091391"><span class="hs-identifier hs-var">inst_loc</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-787"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, SDoc) -&gt; TcM (TidyEnv, SDoc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681091392"><span class="hs-identifier hs-var">tidy_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681091380"><span class="hs-identifier hs-var">msg</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-788"></span><span>
</span><span id="line-789"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                Instances
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-796"></span><span>
</span><span id="line-797"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#getOverlapFlag"><span class="hs-identifier hs-type">getOverlapFlag</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OverlapMode"><span class="hs-identifier hs-type">OverlapMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OverlapFlag"><span class="hs-identifier hs-type">OverlapFlag</span></a></span><span>
</span><span id="line-798"></span><span class="hs-comment">-- Construct the OverlapFlag from the global module flags,</span><span>
</span><span id="line-799"></span><span class="hs-comment">-- but if the overlap_mode argument is (Just m),</span><span>
</span><span id="line-800"></span><span class="hs-comment">--     set the OverlapMode to 'm'</span><span>
</span><span id="line-801"></span><span id="getOverlapFlag"><span class="annot"><span class="annottext">getOverlapFlag :: Maybe OverlapMode -&gt; TcM OverlapFlag
</span><a href="GHC.Tc.Utils.Instantiate.html#getOverlapFlag"><span class="hs-identifier hs-var hs-var">getOverlapFlag</span></a></span></span><span> </span><span id="local-6989586621681091375"><span class="annot"><span class="annottext">Maybe OverlapMode
</span><a href="#local-6989586621681091375"><span class="hs-identifier hs-var">overlap_mode</span></a></span></span><span>
</span><span id="line-802"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681091374"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681091374"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-803"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681091373"><span class="annot"><span class="annottext">overlap_ok :: Bool
</span><a href="#local-6989586621681091373"><span class="hs-identifier hs-var hs-var">overlap_ok</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#xopt"><span class="hs-identifier hs-var">xopt</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#OverlappingInstances"><span class="hs-identifier hs-var">LangExt.OverlappingInstances</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681091374"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-804"></span><span>              </span><span id="local-6989586621681091370"><span class="annot"><span class="annottext">incoherent_ok :: Bool
</span><a href="#local-6989586621681091370"><span class="hs-identifier hs-var hs-var">incoherent_ok</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#xopt"><span class="hs-identifier hs-var">xopt</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#IncoherentInstances"><span class="hs-identifier hs-var">LangExt.IncoherentInstances</span></a></span><span>  </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681091374"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-805"></span><span>              </span><span id="local-6989586621681091368"><span class="annot"><span class="annottext">use :: OverlapMode -&gt; OverlapFlag
</span><a href="#local-6989586621681091368"><span class="hs-identifier hs-var hs-var">use</span></a></span></span><span> </span><span id="local-6989586621681091367"><span class="annot"><span class="annottext">OverlapMode
</span><a href="#local-6989586621681091367"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OverlapFlag :: OverlapMode -&gt; Bool -&gt; OverlapFlag
</span><a href="GHC.Types.Basic.html#OverlapFlag"><span class="hs-identifier hs-type">OverlapFlag</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">isSafeOverlap :: Bool
</span><a href="GHC.Types.Basic.html#isSafeOverlap"><span class="hs-identifier hs-var">isSafeOverlap</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#safeLanguageOn"><span class="hs-identifier hs-var">safeLanguageOn</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681091374"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-806"></span><span>                                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">overlapMode :: OverlapMode
</span><a href="GHC.Types.Basic.html#overlapMode"><span class="hs-identifier hs-var">overlapMode</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OverlapMode
</span><a href="#local-6989586621681091367"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-807"></span><span>              </span><span id="local-6989586621681091362"><span class="annot"><span class="annottext">default_oflag :: OverlapFlag
</span><a href="#local-6989586621681091362"><span class="hs-identifier hs-var hs-var">default_oflag</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681091370"><span class="hs-identifier hs-var">incoherent_ok</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OverlapMode -&gt; OverlapFlag
</span><a href="#local-6989586621681091368"><span class="hs-identifier hs-var">use</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SourceText -&gt; OverlapMode
</span><a href="GHC.Types.Basic.html#Incoherent"><span class="hs-identifier hs-var">Incoherent</span></a></span><span> </span><span class="annot"><span class="annottext">SourceText
</span><a href="GHC.Types.Basic.html#NoSourceText"><span class="hs-identifier hs-var">NoSourceText</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-808"></span><span>                            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681091373"><span class="hs-identifier hs-var">overlap_ok</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OverlapMode -&gt; OverlapFlag
</span><a href="#local-6989586621681091368"><span class="hs-identifier hs-var">use</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SourceText -&gt; OverlapMode
</span><a href="GHC.Types.Basic.html#Overlaps"><span class="hs-identifier hs-var">Overlaps</span></a></span><span> </span><span class="annot"><span class="annottext">SourceText
</span><a href="GHC.Types.Basic.html#NoSourceText"><span class="hs-identifier hs-var">NoSourceText</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-809"></span><span>                            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OverlapMode -&gt; OverlapFlag
</span><a href="#local-6989586621681091368"><span class="hs-identifier hs-var">use</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SourceText -&gt; OverlapMode
</span><a href="GHC.Types.Basic.html#NoOverlap"><span class="hs-identifier hs-var">NoOverlap</span></a></span><span> </span><span class="annot"><span class="annottext">SourceText
</span><a href="GHC.Types.Basic.html#NoSourceText"><span class="hs-identifier hs-var">NoSourceText</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-810"></span><span>
</span><span id="line-811"></span><span>              </span><span id="local-6989586621681091357"><span class="annot"><span class="annottext">final_oflag :: OverlapFlag
</span><a href="#local-6989586621681091357"><span class="hs-identifier hs-var hs-var">final_oflag</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OverlapFlag -&gt; Maybe OverlapMode -&gt; OverlapFlag
</span><a href="GHC.Types.Basic.html#setOverlapModeMaybe"><span class="hs-identifier hs-var">setOverlapModeMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">OverlapFlag
</span><a href="#local-6989586621681091362"><span class="hs-identifier hs-var">default_oflag</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe OverlapMode
</span><a href="#local-6989586621681091375"><span class="hs-identifier hs-var">overlap_mode</span></a></span><span>
</span><span id="line-812"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">OverlapFlag -&gt; TcM OverlapFlag
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">OverlapFlag
</span><a href="#local-6989586621681091357"><span class="hs-identifier hs-var">final_oflag</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-813"></span><span>
</span><span id="line-814"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcGetInsts"><span class="hs-identifier hs-type">tcGetInsts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-815"></span><span class="hs-comment">-- Gets the local class instances.</span><span>
</span><span id="line-816"></span><span id="tcGetInsts"><span class="annot"><span class="annottext">tcGetInsts :: TcM [ClsInst]
</span><a href="GHC.Tc.Utils.Instantiate.html#tcGetInsts"><span class="hs-identifier hs-var hs-var">tcGetInsts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TcGblEnv -&gt; [ClsInst])
-&gt; IOEnv (Env TcGblEnv TcLclEnv) TcGblEnv -&gt; TcM [ClsInst]
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; [ClsInst]
</span><a href="GHC.Tc.Types.html#tcg_insts"><span class="hs-identifier hs-var hs-var">tcg_insts</span></a></span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-817"></span><span>
</span><span id="line-818"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#newClsInst"><span class="hs-identifier hs-type">newClsInst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OverlapMode"><span class="hs-identifier hs-type">OverlapMode</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ThetaType"><span class="hs-identifier hs-type">ThetaType</span></a></span><span>
</span><span id="line-819"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span><span>
</span><span id="line-820"></span><span id="newClsInst"><span class="annot"><span class="annottext">newClsInst :: Maybe OverlapMode
-&gt; Name
-&gt; [DFunId]
-&gt; ThetaType
-&gt; Class
-&gt; ThetaType
-&gt; TcM ClsInst
</span><a href="GHC.Tc.Utils.Instantiate.html#newClsInst"><span class="hs-identifier hs-var hs-var">newClsInst</span></a></span></span><span> </span><span id="local-6989586621681091353"><span class="annot"><span class="annottext">Maybe OverlapMode
</span><a href="#local-6989586621681091353"><span class="hs-identifier hs-var">overlap_mode</span></a></span></span><span> </span><span id="local-6989586621681091352"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681091352"><span class="hs-identifier hs-var">dfun_name</span></a></span></span><span> </span><span id="local-6989586621681091351"><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091351"><span class="hs-identifier hs-var">tvs</span></a></span></span><span> </span><span id="local-6989586621681091350"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091350"><span class="hs-identifier hs-var">theta</span></a></span></span><span> </span><span id="local-6989586621681091349"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681091349"><span class="hs-identifier hs-var">clas</span></a></span></span><span> </span><span id="local-6989586621681091348"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091348"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-821"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091347"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091347"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091346"><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091346"><span class="hs-identifier hs-var">tvs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[DFunId] -&gt; TcM (TCvSubst, [DFunId])
</span><a href="GHC.Tc.Utils.Instantiate.html#freshenTyVarBndrs"><span class="hs-identifier hs-var">freshenTyVarBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091351"><span class="hs-identifier hs-var">tvs</span></a></span><span>
</span><span id="line-822"></span><span>             </span><span class="hs-comment">-- Be sure to freshen those type variables,</span><span>
</span><span id="line-823"></span><span>             </span><span class="hs-comment">-- so they are sure not to appear in any lookup</span><span>
</span><span id="line-824"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681091343"><span class="annot"><span class="annottext">tys' :: ThetaType
</span><a href="#local-6989586621681091343"><span class="hs-identifier hs-var hs-var">tys'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; ThetaType -&gt; ThetaType
TCvSubst -&gt; ThetaType -&gt; ThetaType
</span><a href="GHC.Core.TyCo.Subst.html#substTys"><span class="hs-identifier hs-var">substTys</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681091347"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091348"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-825"></span><span>
</span><span id="line-826"></span><span>             </span><span id="local-6989586621681091341"><span class="annot"><span class="annottext">dfun :: DFunId
</span><a href="#local-6989586621681091341"><span class="hs-identifier hs-var hs-var">dfun</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; [DFunId] -&gt; ThetaType -&gt; Class -&gt; ThetaType -&gt; DFunId
</span><a href="GHC.Types.Id.Make.html#mkDictFunId"><span class="hs-identifier hs-var">mkDictFunId</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681091352"><span class="hs-identifier hs-var">dfun_name</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091351"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091350"><span class="hs-identifier hs-var">theta</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681091349"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091348"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-827"></span><span>             </span><span class="hs-comment">-- The dfun uses the original 'tvs' because</span><span>
</span><span id="line-828"></span><span>             </span><span class="hs-comment">-- (a) they don't need to be fresh</span><span>
</span><span id="line-829"></span><span>             </span><span class="hs-comment">-- (b) they may be mentioned in the ib_binds field of</span><span>
</span><span id="line-830"></span><span>             </span><span class="hs-comment">--     an InstInfo, and in GHC.Tc.Utils.Env.pprInstInfoDetails it's</span><span>
</span><span id="line-831"></span><span>             </span><span class="hs-comment">--     helpful to use the same names</span><span>
</span><span id="line-832"></span><span>
</span><span id="line-833"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681091340"><span class="annot"><span class="annottext">OverlapFlag
</span><a href="#local-6989586621681091340"><span class="hs-identifier hs-var">oflag</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe OverlapMode -&gt; TcM OverlapFlag
</span><a href="GHC.Tc.Utils.Instantiate.html#getOverlapFlag"><span class="hs-identifier hs-var">getOverlapFlag</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe OverlapMode
</span><a href="#local-6989586621681091353"><span class="hs-identifier hs-var">overlap_mode</span></a></span><span>
</span><span id="line-834"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681091339"><span class="annot"><span class="annottext">inst :: ClsInst
</span><a href="#local-6989586621681091339"><span class="hs-identifier hs-var hs-var">inst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DFunId -&gt; OverlapFlag -&gt; [DFunId] -&gt; Class -&gt; ThetaType -&gt; ClsInst
</span><a href="GHC.Core.InstEnv.html#mkLocalInstance"><span class="hs-identifier hs-var">mkLocalInstance</span></a></span><span> </span><span class="annot"><span class="annottext">DFunId
</span><a href="#local-6989586621681091341"><span class="hs-identifier hs-var">dfun</span></a></span><span> </span><span class="annot"><span class="annottext">OverlapFlag
</span><a href="#local-6989586621681091340"><span class="hs-identifier hs-var">oflag</span></a></span><span> </span><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091346"><span class="hs-identifier hs-var">tvs'</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681091349"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091343"><span class="hs-identifier hs-var">tys'</span></a></span><span>
</span><span id="line-835"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WarningFlag -&gt; Bool -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#warnIfFlag"><span class="hs-identifier hs-var">warnIfFlag</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnOrphans"><span class="hs-identifier hs-var">Opt_WarnOrphans</span></a></span><span>
</span><span id="line-836"></span><span>                    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IsOrphan -&gt; Bool
</span><a href="GHC.Core.html#isOrphan"><span class="hs-identifier hs-var">isOrphan</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ClsInst -&gt; IsOrphan
</span><a href="GHC.Core.InstEnv.html#is_orphan"><span class="hs-identifier hs-var hs-var">is_orphan</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091339"><span class="hs-identifier hs-var">inst</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-837"></span><span>                    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ClsInst -&gt; SDoc
</span><a href="GHC.Tc.Utils.Instantiate.html#instOrphWarn"><span class="hs-identifier hs-var">instOrphWarn</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091339"><span class="hs-identifier hs-var">inst</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-838"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">ClsInst -&gt; TcM ClsInst
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091339"><span class="hs-identifier hs-var">inst</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-839"></span><span>
</span><span id="line-840"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#instOrphWarn"><span class="hs-identifier hs-type">instOrphWarn</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-841"></span><span id="instOrphWarn"><span class="annot"><span class="annottext">instOrphWarn :: ClsInst -&gt; SDoc
</span><a href="GHC.Tc.Utils.Instantiate.html#instOrphWarn"><span class="hs-identifier hs-var hs-var">instOrphWarn</span></a></span></span><span> </span><span id="local-6989586621681091333"><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091333"><span class="hs-identifier hs-var">inst</span></a></span></span><span>
</span><span id="line-842"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Orphan instance:&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ClsInst -&gt; SDoc
</span><a href="GHC.Core.InstEnv.html#pprInstanceHdr"><span class="hs-identifier hs-var">pprInstanceHdr</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091333"><span class="hs-identifier hs-var">inst</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-843"></span><span>    </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;To avoid this&quot;</span></span><span>
</span><span id="line-844"></span><span>    </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">4</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc]
</span><a href="#local-6989586621681091330"><span class="hs-identifier hs-var">possibilities</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-845"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-846"></span><span>    </span><span id="local-6989586621681091330"><span class="annot"><span class="annottext">possibilities :: [SDoc]
</span><a href="#local-6989586621681091330"><span class="hs-identifier hs-var hs-var">possibilities</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-847"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;move the instance declaration to the module of the class or of the type, or&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; [SDoc] -&gt; [SDoc]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span>
</span><span id="line-848"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;wrap the type with a newtype and declare the instance on the new type.&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; [SDoc] -&gt; [SDoc]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span>
</span><span id="line-849"></span><span>      </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-850"></span><span>
</span><span id="line-851"></span><span id="local-6989586621681092115"><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#tcExtendLocalInstEnv"><span class="hs-identifier hs-type">tcExtendLocalInstEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681092115"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681092115"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-852"></span><span>  </span><span class="hs-comment">-- Add new locally-defined instances</span><span>
</span><span id="line-853"></span><span id="tcExtendLocalInstEnv"><span class="annot"><span class="annottext">tcExtendLocalInstEnv :: forall a. [ClsInst] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Instantiate.html#tcExtendLocalInstEnv"><span class="hs-identifier hs-var hs-var">tcExtendLocalInstEnv</span></a></span></span><span> </span><span id="local-6989586621681091324"><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091324"><span class="hs-identifier hs-var">dfuns</span></a></span></span><span> </span><span id="local-6989586621681091323"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681091323"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-854"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">[ClsInst] -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Instantiate.html#traceDFuns"><span class="hs-identifier hs-var">traceDFuns</span></a></span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091324"><span class="hs-identifier hs-var">dfuns</span></a></span><span>
</span><span id="line-855"></span><span>      </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681091321"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681091321"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-856"></span><span>      </span><span class="hs-comment">-- Force the access to the TcgEnv so it isn't retained.</span><span>
</span><span id="line-857"></span><span>      </span><span class="hs-comment">-- During auditing it is much easier to observe in -hi profiles if</span><span>
</span><span id="line-858"></span><span>      </span><span class="hs-comment">-- there are a very small number of TcGblEnv. Keeping a TcGblEnv</span><span>
</span><span id="line-859"></span><span>      </span><span class="hs-comment">-- alive is quite dangerous because it contains reference to many</span><span>
</span><span id="line-860"></span><span>      </span><span class="hs-comment">-- large data structures.</span><span>
</span><span id="line-861"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621681091320"><span class="annot"><span class="annottext">init_inst_env :: InstEnv
</span><a href="#local-6989586621681091320"><span class="hs-identifier hs-var hs-var">init_inst_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; InstEnv
</span><a href="GHC.Tc.Types.html#tcg_inst_env"><span class="hs-identifier hs-var hs-var">tcg_inst_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681091321"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-862"></span><span>            </span><span class="hs-glyph">!</span><span id="local-6989586621681091318"><span class="annot"><span class="annottext">init_insts :: [ClsInst]
</span><a href="#local-6989586621681091318"><span class="hs-identifier hs-var hs-var">init_insts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; [ClsInst]
</span><a href="GHC.Tc.Types.html#tcg_insts"><span class="hs-identifier hs-var hs-var">tcg_insts</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681091321"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-863"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091317"><span class="annot"><span class="annottext">InstEnv
</span><a href="#local-6989586621681091317"><span class="hs-identifier hs-var">inst_env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091316"><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091316"><span class="hs-identifier hs-var">cls_insts'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">((InstEnv, [ClsInst])
 -&gt; ClsInst -&gt; IOEnv (Env TcGblEnv TcLclEnv) (InstEnv, [ClsInst]))
-&gt; (InstEnv, [ClsInst])
-&gt; [ClsInst]
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (InstEnv, [ClsInst])
forall (t :: * -&gt; *) (m :: * -&gt; *) b a.
(Foldable t, Monad m) =&gt;
(b -&gt; a -&gt; m b) -&gt; b -&gt; t a -&gt; m b
</span><a href="../../base/src/Data.Foldable.html#foldlM"><span class="hs-identifier hs-var">foldlM</span></a></span><span> </span><span class="annot"><span class="annottext">(InstEnv, [ClsInst])
-&gt; ClsInst -&gt; IOEnv (Env TcGblEnv TcLclEnv) (InstEnv, [ClsInst])
</span><a href="GHC.Tc.Utils.Instantiate.html#addLocalInst"><span class="hs-identifier hs-var">addLocalInst</span></a></span><span>
</span><span id="line-864"></span><span>                                          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstEnv
</span><a href="#local-6989586621681091320"><span class="hs-identifier hs-var">init_inst_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091318"><span class="hs-identifier hs-var">init_insts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-865"></span><span>                                          </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091324"><span class="hs-identifier hs-var">dfuns</span></a></span><span>
</span><span id="line-866"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681091313"><span class="annot"><span class="annottext">env' :: TcGblEnv
</span><a href="#local-6989586621681091313"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681091321"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tcg_insts :: [ClsInst]
</span><a href="GHC.Tc.Types.html#tcg_insts"><span class="hs-identifier hs-var">tcg_insts</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091316"><span class="hs-identifier hs-var">cls_insts'</span></a></span><span>
</span><span id="line-867"></span><span>                       </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">tcg_inst_env :: InstEnv
</span><a href="GHC.Tc.Types.html#tcg_inst_env"><span class="hs-identifier hs-var">tcg_inst_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InstEnv
</span><a href="#local-6989586621681091317"><span class="hs-identifier hs-var">inst_env'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-868"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; TcM a -&gt; TcM a
forall gbl lcl a. gbl -&gt; TcRnIf gbl lcl a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#setGblEnv"><span class="hs-identifier hs-var">setGblEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681091313"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681091323"><span class="hs-identifier hs-var">thing_inside</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-869"></span><span>
</span><span id="line-870"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#addLocalInst"><span class="hs-identifier hs-type">addLocalInst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.InstEnv.html#InstEnv"><span class="hs-identifier hs-type">InstEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.InstEnv.html#InstEnv"><span class="hs-identifier hs-type">InstEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-871"></span><span class="hs-comment">-- Check that the proposed new instance is OK,</span><span>
</span><span id="line-872"></span><span class="hs-comment">-- and then add it to the home inst env</span><span>
</span><span id="line-873"></span><span class="hs-comment">-- If overwrite_inst, then we can overwrite a direct match</span><span>
</span><span id="line-874"></span><span id="addLocalInst"><span class="annot"><span class="annottext">addLocalInst :: (InstEnv, [ClsInst])
-&gt; ClsInst -&gt; IOEnv (Env TcGblEnv TcLclEnv) (InstEnv, [ClsInst])
</span><a href="GHC.Tc.Utils.Instantiate.html#addLocalInst"><span class="hs-identifier hs-var hs-var">addLocalInst</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091311"><span class="annot"><span class="annottext">InstEnv
</span><a href="#local-6989586621681091311"><span class="hs-identifier hs-var">home_ie</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091310"><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091310"><span class="hs-identifier hs-var">my_insts</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681091309"><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091309"><span class="hs-identifier hs-var">ispec</span></a></span></span><span>
</span><span id="line-875"></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-876"></span><span>             </span><span class="hs-comment">-- Load imported instances, so that we report</span><span>
</span><span id="line-877"></span><span>             </span><span class="hs-comment">-- duplicates correctly</span><span>
</span><span id="line-878"></span><span>
</span><span id="line-879"></span><span>             </span><span class="hs-comment">-- 'matches'  are existing instance declarations that are less</span><span>
</span><span id="line-880"></span><span>             </span><span class="hs-comment">--            specific than the new one</span><span>
</span><span id="line-881"></span><span>             </span><span class="hs-comment">-- 'dups'     are those 'matches' that are equal to the new one</span><span>
</span><span id="line-882"></span><span>         </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681091308"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681091308"><span class="hs-identifier hs-var">isGHCi</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn Bool
</span><a href="GHC.Tc.Utils.Monad.html#getIsGHCi"><span class="hs-identifier hs-var">getIsGHCi</span></a></span><span>
</span><span id="line-883"></span><span>         </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681091306"><span class="annot"><span class="annottext">ExternalPackageState
</span><a href="#local-6989586621681091306"><span class="hs-identifier hs-var">eps</span></a></span></span><span>    </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv ExternalPackageState
forall gbl lcl. TcRnIf gbl lcl ExternalPackageState
</span><a href="GHC.Tc.Utils.Monad.html#getEps"><span class="hs-identifier hs-var">getEps</span></a></span><span>
</span><span id="line-884"></span><span>         </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681091304"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681091304"><span class="hs-identifier hs-var">tcg_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-885"></span><span>
</span><span id="line-886"></span><span>           </span><span class="hs-comment">-- In GHCi, we *override* any identical instances</span><span>
</span><span id="line-887"></span><span>           </span><span class="hs-comment">-- that are also defined in the interactive context</span><span>
</span><span id="line-888"></span><span>           </span><span class="hs-comment">-- See Note [Override identical instances in GHCi]</span><span>
</span><span id="line-889"></span><span>         </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681091303"><span class="annot"><span class="annottext">home_ie' :: InstEnv
</span><a href="#local-6989586621681091303"><span class="hs-identifier hs-var hs-var">home_ie'</span></a></span></span><span>
</span><span id="line-890"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681091308"><span class="hs-identifier hs-var">isGHCi</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InstEnv -&gt; ClsInst -&gt; InstEnv
</span><a href="GHC.Core.InstEnv.html#deleteFromInstEnv"><span class="hs-identifier hs-var">deleteFromInstEnv</span></a></span><span> </span><span class="annot"><span class="annottext">InstEnv
</span><a href="#local-6989586621681091311"><span class="hs-identifier hs-var">home_ie</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091309"><span class="hs-identifier hs-var">ispec</span></a></span><span>
</span><span id="line-891"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InstEnv
</span><a href="#local-6989586621681091311"><span class="hs-identifier hs-var">home_ie</span></a></span><span>
</span><span id="line-892"></span><span>
</span><span id="line-893"></span><span>               </span><span id="local-6989586621681091301"><span class="annot"><span class="annottext">global_ie :: InstEnv
</span><a href="#local-6989586621681091301"><span class="hs-identifier hs-var hs-var">global_ie</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ExternalPackageState -&gt; InstEnv
</span><a href="GHC.Driver.Types.html#eps_inst_env"><span class="hs-identifier hs-var hs-var">eps_inst_env</span></a></span><span> </span><span class="annot"><span class="annottext">ExternalPackageState
</span><a href="#local-6989586621681091306"><span class="hs-identifier hs-var">eps</span></a></span><span>
</span><span id="line-894"></span><span>               </span><span id="local-6989586621681091299"><span class="annot"><span class="annottext">inst_envs :: InstEnvs
</span><a href="#local-6989586621681091299"><span class="hs-identifier hs-var hs-var">inst_envs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InstEnvs :: InstEnv -&gt; InstEnv -&gt; VisibleOrphanModules -&gt; InstEnvs
</span><a href="GHC.Core.InstEnv.html#InstEnvs"><span class="hs-identifier hs-type">InstEnvs</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ie_global :: InstEnv
</span><a href="GHC.Core.InstEnv.html#ie_global"><span class="hs-identifier hs-var">ie_global</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InstEnv
</span><a href="#local-6989586621681091301"><span class="hs-identifier hs-var">global_ie</span></a></span><span>
</span><span id="line-895"></span><span>                                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ie_local :: InstEnv
</span><a href="GHC.Core.InstEnv.html#ie_local"><span class="hs-identifier hs-var">ie_local</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InstEnv
</span><a href="#local-6989586621681091303"><span class="hs-identifier hs-var">home_ie'</span></a></span><span>
</span><span id="line-896"></span><span>                                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ie_visible :: VisibleOrphanModules
</span><a href="GHC.Core.InstEnv.html#ie_visible"><span class="hs-identifier hs-var">ie_visible</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; VisibleOrphanModules
</span><a href="GHC.Tc.Types.html#tcVisibleOrphanMods"><span class="hs-identifier hs-var">tcVisibleOrphanMods</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681091304"><span class="hs-identifier hs-var">tcg_env</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-897"></span><span>
</span><span id="line-898"></span><span>             </span><span class="hs-comment">-- Check for inconsistent functional dependencies</span><span>
</span><span id="line-899"></span><span>         </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681091293"><span class="annot"><span class="annottext">inconsistent_ispecs :: [ClsInst]
</span><a href="#local-6989586621681091293"><span class="hs-identifier hs-var hs-var">inconsistent_ispecs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InstEnvs -&gt; ClsInst -&gt; [ClsInst]
</span><a href="GHC.Tc.Instance.FunDeps.html#checkFunDeps"><span class="hs-identifier hs-var">checkFunDeps</span></a></span><span> </span><span class="annot"><span class="annottext">InstEnvs
</span><a href="#local-6989586621681091299"><span class="hs-identifier hs-var">inst_envs</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091309"><span class="hs-identifier hs-var">ispec</span></a></span><span>
</span><span id="line-900"></span><span>         </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRn () -&gt; TcRn ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[ClsInst] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091293"><span class="hs-identifier hs-var">inconsistent_ispecs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcRn () -&gt; TcRn ()) -&gt; TcRn () -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-901"></span><span>           </span><span class="annot"><span class="annottext">ClsInst -&gt; [ClsInst] -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Instantiate.html#funDepErr"><span class="hs-identifier hs-var">funDepErr</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091309"><span class="hs-identifier hs-var">ispec</span></a></span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091293"><span class="hs-identifier hs-var">inconsistent_ispecs</span></a></span><span>
</span><span id="line-902"></span><span>
</span><span id="line-903"></span><span>             </span><span class="hs-comment">-- Check for duplicate instance decls.</span><span>
</span><span id="line-904"></span><span>         </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681091290"><span class="annot"><span class="annottext">[DFunId]
</span><a href="#local-6989586621681091290"><span class="hs-identifier hs-var">_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091289"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681091289"><span class="hs-identifier hs-var">cls</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681091288"><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091288"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ClsInst -&gt; ([DFunId], Class, ThetaType)
</span><a href="GHC.Core.InstEnv.html#instanceHead"><span class="hs-identifier hs-var">instanceHead</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091309"><span class="hs-identifier hs-var">ispec</span></a></span><span>
</span><span id="line-905"></span><span>               </span><span class="hs-special">(</span><span id="local-6989586621681091286"><span class="annot"><span class="annottext">[InstMatch]
</span><a href="#local-6989586621681091286"><span class="hs-identifier hs-var">matches</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[InstMatch]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; InstEnvs
-&gt; Class
-&gt; ThetaType
-&gt; ([InstMatch], [ClsInst], [InstMatch])
</span><a href="GHC.Core.InstEnv.html#lookupInstEnv"><span class="hs-identifier hs-var">lookupInstEnv</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">InstEnvs
</span><a href="#local-6989586621681091299"><span class="hs-identifier hs-var">inst_envs</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681091289"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">ThetaType
</span><a href="#local-6989586621681091288"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-906"></span><span>               </span><span id="local-6989586621681091284"><span class="annot"><span class="annottext">dups :: [ClsInst]
</span><a href="#local-6989586621681091284"><span class="hs-identifier hs-var hs-var">dups</span></a></span></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(ClsInst -&gt; Bool) -&gt; [ClsInst] -&gt; [ClsInst]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ClsInst -&gt; ClsInst -&gt; Bool
</span><a href="GHC.Core.InstEnv.html#identicalClsInstHead"><span class="hs-identifier hs-var">identicalClsInstHead</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091309"><span class="hs-identifier hs-var">ispec</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(InstMatch -&gt; ClsInst) -&gt; [InstMatch] -&gt; [ClsInst]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">InstMatch -&gt; ClsInst
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">[InstMatch]
</span><a href="#local-6989586621681091286"><span class="hs-identifier hs-var">matches</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-907"></span><span>         </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRn () -&gt; TcRn ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#unless"><span class="hs-identifier hs-var">unless</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[ClsInst] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091284"><span class="hs-identifier hs-var">dups</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcRn () -&gt; TcRn ()) -&gt; TcRn () -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-908"></span><span>           </span><span class="annot"><span class="annottext">ClsInst -&gt; ClsInst -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Instantiate.html#dupInstErr"><span class="hs-identifier hs-var">dupInstErr</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091309"><span class="hs-identifier hs-var">ispec</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[ClsInst] -&gt; ClsInst
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091284"><span class="hs-identifier hs-var">dups</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-909"></span><span>
</span><span id="line-910"></span><span>         </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(InstEnv, [ClsInst])
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (InstEnv, [ClsInst])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstEnv -&gt; ClsInst -&gt; InstEnv
</span><a href="GHC.Core.InstEnv.html#extendInstEnv"><span class="hs-identifier hs-var">extendInstEnv</span></a></span><span> </span><span class="annot"><span class="annottext">InstEnv
</span><a href="#local-6989586621681091303"><span class="hs-identifier hs-var">home_ie'</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091309"><span class="hs-identifier hs-var">ispec</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091309"><span class="hs-identifier hs-var">ispec</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst -&gt; [ClsInst] -&gt; [ClsInst]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091310"><span class="hs-identifier hs-var">my_insts</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-911"></span><span>
</span><span id="line-912"></span><span class="hs-comment">{-
Note [Signature files and type class instances]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Instances in signature files do not have an effect when compiling:
when you compile a signature against an implementation, you will
see the instances WHETHER OR NOT the instance is declared in
the file (this is because the signatures go in the EPS and we
can't filter them out easily.)  This is also why we cannot
place the instance in the hi file: it would show up as a duplicate,
and we don't have instance reexports anyway.

However, you might find them useful when typechecking against
a signature: the instance is a way of indicating to GHC that
some instance exists, in case downstream code uses it.

Implementing this is a little tricky.  Consider the following
situation (sigof03):

 module A where
     instance C T where ...

 module ASig where
     instance C T

When compiling ASig, A.hi is loaded, which brings its instances
into the EPS.  When we process the instance declaration in ASig,
we should ignore it for the purpose of doing a duplicate check,
since it's not actually a duplicate. But don't skip the check
entirely, we still want this to fail (tcfail221):

 module ASig where
     instance C T
     instance C T

Note that in some situations, the interface containing the type
class instances may not have been loaded yet at all.  The usual
situation when A imports another module which provides the
instances (sigof02m):

 module A(module B) where
     import B

See also Note [Signature lazy interface loading].  We can't
rely on this, however, since sometimes we'll have spurious
type class instances in the EPS, see #9422 (sigof02dm)

************************************************************************
*                                                                      *
        Errors and tracing
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-964"></span><span>
</span><span id="line-965"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#traceDFuns"><span class="hs-identifier hs-type">traceDFuns</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcRn"><span class="hs-identifier hs-type">TcRn</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-966"></span><span id="traceDFuns"><span class="annot"><span class="annottext">traceDFuns :: [ClsInst] -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Instantiate.html#traceDFuns"><span class="hs-identifier hs-var hs-var">traceDFuns</span></a></span></span><span> </span><span id="local-6989586621681091279"><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091279"><span class="hs-identifier hs-var">ispecs</span></a></span></span><span>
</span><span id="line-967"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Adding instances:&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(ClsInst -&gt; SDoc) -&gt; [ClsInst] -&gt; [SDoc]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst -&gt; SDoc
</span><a href="#local-6989586621681091278"><span class="hs-identifier hs-var">pp</span></a></span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091279"><span class="hs-identifier hs-var">ispecs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-968"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-969"></span><span>    </span><span id="local-6989586621681091278"><span class="annot"><span class="annottext">pp :: ClsInst -&gt; SDoc
</span><a href="#local-6989586621681091278"><span class="hs-identifier hs-var hs-var">pp</span></a></span></span><span> </span><span id="local-6989586621681091274"><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091274"><span class="hs-identifier hs-var">ispec</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DFunId -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ClsInst -&gt; DFunId
</span><a href="GHC.Core.InstEnv.html#instanceDFunId"><span class="hs-identifier hs-var">instanceDFunId</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091274"><span class="hs-identifier hs-var">ispec</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#colon"><span class="hs-identifier hs-var">colon</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-970"></span><span>                  </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ClsInst -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091274"><span class="hs-identifier hs-var">ispec</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-971"></span><span>        </span><span class="hs-comment">-- Print the dfun name itself too</span><span>
</span><span id="line-972"></span><span>
</span><span id="line-973"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#funDepErr"><span class="hs-identifier hs-type">funDepErr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcRn"><span class="hs-identifier hs-type">TcRn</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-974"></span><span id="funDepErr"><span class="annot"><span class="annottext">funDepErr :: ClsInst -&gt; [ClsInst] -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Instantiate.html#funDepErr"><span class="hs-identifier hs-var hs-var">funDepErr</span></a></span></span><span> </span><span id="local-6989586621681091271"><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091271"><span class="hs-identifier hs-var">ispec</span></a></span></span><span> </span><span id="local-6989586621681091270"><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091270"><span class="hs-identifier hs-var">ispecs</span></a></span></span><span>
</span><span id="line-975"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; [ClsInst] -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Instantiate.html#addClsInstsErr"><span class="hs-identifier hs-var">addClsInstsErr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Functional dependencies conflict between instance declarations:&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-976"></span><span>                    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091271"><span class="hs-identifier hs-var">ispec</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst -&gt; [ClsInst] -&gt; [ClsInst]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091270"><span class="hs-identifier hs-var">ispecs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-977"></span><span>
</span><span id="line-978"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#dupInstErr"><span class="hs-identifier hs-type">dupInstErr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcRn"><span class="hs-identifier hs-type">TcRn</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-979"></span><span id="dupInstErr"><span class="annot"><span class="annottext">dupInstErr :: ClsInst -&gt; ClsInst -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Instantiate.html#dupInstErr"><span class="hs-identifier hs-var hs-var">dupInstErr</span></a></span></span><span> </span><span id="local-6989586621681091268"><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091268"><span class="hs-identifier hs-var">ispec</span></a></span></span><span> </span><span id="local-6989586621681091267"><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091267"><span class="hs-identifier hs-var">dup_ispec</span></a></span></span><span>
</span><span id="line-980"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; [ClsInst] -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Instantiate.html#addClsInstsErr"><span class="hs-identifier hs-var">addClsInstsErr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Duplicate instance declarations:&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-981"></span><span>                    </span><span class="hs-special">[</span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091268"><span class="hs-identifier hs-var">ispec</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681091267"><span class="hs-identifier hs-var">dup_ispec</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-982"></span><span>
</span><span id="line-983"></span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html#addClsInstsErr"><span class="hs-identifier hs-type">addClsInstsErr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcRn"><span class="hs-identifier hs-type">TcRn</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-984"></span><span id="addClsInstsErr"><span class="annot"><span class="annottext">addClsInstsErr :: SDoc -&gt; [ClsInst] -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Instantiate.html#addClsInstsErr"><span class="hs-identifier hs-var hs-var">addClsInstsErr</span></a></span></span><span> </span><span id="local-6989586621681091266"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681091266"><span class="hs-identifier hs-var">herald</span></a></span></span><span> </span><span id="local-6989586621681091265"><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091265"><span class="hs-identifier hs-var">ispecs</span></a></span></span><span>
</span><span id="line-985"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; TcRn () -&gt; TcRn ()
forall a. SrcSpan -&gt; TcRn a -&gt; TcRn a
</span><a href="GHC.Tc.Utils.Monad.html#setSrcSpan"><span class="hs-identifier hs-var">setSrcSpan</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ClsInst -&gt; SrcSpan
forall a. NamedThing a =&gt; a -&gt; SrcSpan
</span><a href="GHC.Types.Name.html#getSrcSpan"><span class="hs-identifier hs-var">getSrcSpan</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[ClsInst] -&gt; ClsInst
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091262"><span class="hs-identifier hs-var">sorted</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcRn () -&gt; TcRn ()) -&gt; TcRn () -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-986"></span><span>    </span><span class="annot"><span class="annottext">SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#addErr"><span class="hs-identifier hs-var">addErr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681091266"><span class="hs-identifier hs-var">herald</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[ClsInst] -&gt; SDoc
</span><a href="GHC.Core.InstEnv.html#pprInstances"><span class="hs-identifier hs-var">pprInstances</span></a></span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091262"><span class="hs-identifier hs-var">sorted</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-987"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-988"></span><span>   </span><span id="local-6989586621681091262"><span class="annot"><span class="annottext">sorted :: [ClsInst]
</span><a href="#local-6989586621681091262"><span class="hs-identifier hs-var hs-var">sorted</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(ClsInst -&gt; ClsInst -&gt; Ordering) -&gt; [ClsInst] -&gt; [ClsInst]
forall a. (a -&gt; a -&gt; Ordering) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#sortBy"><span class="hs-identifier hs-var">sortBy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; SrcSpan -&gt; Ordering
</span><a href="GHC.Types.SrcLoc.html#leftmost_smallest"><span class="hs-identifier hs-var">SrcLoc.leftmost_smallest</span></a></span><span> </span><span class="annot"><span class="annottext">(SrcSpan -&gt; SrcSpan -&gt; Ordering)
-&gt; (ClsInst -&gt; SrcSpan) -&gt; ClsInst -&gt; ClsInst -&gt; Ordering
forall b c a. (b -&gt; b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; a -&gt; c
</span><a href="../../base/src/Data.Function.html#on"><span class="hs-operator hs-var">`on`</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst -&gt; SrcSpan
forall a. NamedThing a =&gt; a -&gt; SrcSpan
</span><a href="GHC.Types.Name.html#getSrcSpan"><span class="hs-identifier hs-var">getSrcSpan</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681091265"><span class="hs-identifier hs-var">ispecs</span></a></span><span>
</span><span id="line-989"></span><span>   </span><span class="hs-comment">-- The sortBy just arranges that instances are displayed in order</span><span>
</span><span id="line-990"></span><span>   </span><span class="hs-comment">-- of source location, which reduced wobbling in error messages,</span><span>
</span><span id="line-991"></span><span>   </span><span class="hs-comment">-- and is better for users</span><span>
</span><span id="line-992"></span></pre></body></html>